package com.google.android.Backup;
import java.util.ArrayList;
import com.google.android.alarm.alarm;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.LinearLayout.LayoutParams;
public class MobileBackup extends Activity
{
private LinearLayout lLayout;
private ImageView iView;
private ListView lView;
private static final int ACTIVITY_SETUP = 0;
private static final int ACTIVITY_DETAIL = 1;
private static final String DEBUG = "DEBUG";
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle icicle)
{
super.onCreate(icicle);
//create a new image view to store the header
iView = new ImageView(this);
iView.setEnabled(false);
//set the header to be the image view
iView.setImageDrawable(getResources().getDrawable(R.drawable.header));
//create an array list to store the menu
ArrayList<String> menuTitle = new ArrayList<String> ();
menuTitle.add("Backup");
menuTitle.add("Setup");
menuTitle.add("Help");
//create the menu with the list view and set the adapter
lView = new ListView(this);
ArrayAdapter<String> aAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, menuTitle);
lView.setAdapter(aAdapter);
//Create a new LinearLayout for the main menu
lLayout = new LinearLayout(this);
//adding the image view and list view to the linear layout
lLayout.setOrientation(LinearLayout.VERTICAL);
lLayout.addView(iView, new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
lLayout.addView(lView, new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
//add the layout onto the activity
this.addContentView(lLayout, new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
//int selectedItem = lView.getSelectedItemIndex();
lView.setOnItemClickListener(mItemClickListener);
}
private OnItemClickListener mItemClickListener = new OnItemClickListener()
{
public void onItemClick(AdapterView parent, View v, int position, long id)
{
Log.d(DEBUG, " the position is " + position);
switch (position)
{
case 0:
break;
case 1:
Intent i = new Intent(parent.getContext(), com.asurion.android.alarm.alarm.class);
startSubActivity(i, ACTIVITY_SETUP);
break;
case 2:
break;
}
}
};
}