我希望能够使用 Intent 类开始一个新活动。我知道如何使用这些代码行开始活动:
Intent myIntent = new Intent(v.getContext(), bylocationactivity.class);
startActivityForResult(myIntent, 0);
但是我如何指定单击了哪个项目?所以当我点击“按位置”时,我可以启动 bylocationactivity.class 等等?
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)
{
}
});
}
}