I want to start a new activity using the Intent class. I know how to get started using these lines of code:
Intent myIntent = new Intent(v.getContext(), bylocationactivity.class);
startActivityForResult(myIntent, 0);
But how can I indicate which item was clicked? So when I click "By Location", can I run the bylocationactivity.class class, etc.?
public class bonesactivity extends Activity
{
public void onCreate(Bundle savedInstanceState)
{
ListView boneslist;
String categorieslist[]={"Alphabetically","By Location","Specialty Tests"};
super.onCreate(savedInstanceState);
setContentView(R.layout.boneslayout);
boneslist=(ListView)findViewById(R.id.boneslayout);
boneslist.setAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1 , categorieslist));
boneslist.setOnItemClickListener(new OnItemClickListener()
{
public void onItemClick(AdapterView<?> parent, View view,int position, long id)
{
}
});
}
}
source
share