Sunday, 23 December 2012

How to create a Listview action provider in android

public


class Mainclass extends ListActivity {
String
apps[]={"MainActivity","Games","Shareclass","TOPAPPS","Lifestyle","Latestdownloads","angrybirds","updates","newandroidapps","new gadgets","android phones","new dell Laptops"};
String
clickapps;
Class<?>
ourclass;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
//setContentView(R.layout.second);
//ListView lv=(ListView)findViewById(R.id.listView1);
setListAdapter(
new ArrayAdapter<String>(Mainclass.this, android.R.layout.simple_list_item_1, apps));
  }
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
// TODO Auto-generated method stub
super.onListItemClick(l, v, position, id);
clickapps=apps[position];
try {
ourclass = Class.forName("com.example.internetactionbar."+clickapps);
}
catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Intent intent=
new Intent(Mainclass.this,ourclass);
startActivity(intent);


output will the following :






No comments:

Post a Comment