安卓ListView问题如何实现点击一行,跳转到另一个activity
像这样随意点一行后,如何跳到下一个界面ArrayAdapter<CharSequence>adapter=ArrayAdapter.createFromResource(...
像这样随意点一行后,如何跳到下一个界面
ArrayAdapter<CharSequence>adapter=ArrayAdapter.createFromResource(this, R.array.tut_titles,
android.R.layout.simple_list_item_checked);
listView.setAdapter(adapter);
listView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
String result = parent.getItemAtPosition(position).toString();
}
});然后咋写嘞 展开
ArrayAdapter<CharSequence>adapter=ArrayAdapter.createFromResource(this, R.array.tut_titles,
android.R.layout.simple_list_item_checked);
listView.setAdapter(adapter);
listView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
String result = parent.getItemAtPosition(position).toString();
}
});然后咋写嘞 展开
展开全部
假设listview命名为list。
list.setOnItemClickListener(itemClick);
AdapterView.OnItemClickListener itemClick = new AdapterView.OnItemClickListener()
{
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id)
{
switch (parent.getId())
{
case R.id.listview:
expressItemClick(position);//position 代表你点的哪一个
break;
}
}
};
public void expressitemClick(int postion){
Intent intent = new Intent(当前的.class,下一个页面的.class);
startActivity(intent);
finish();//看你需不需要返回当前界面,如果点返回需要返回到当前界面,就不用这个
}
list.setOnItemClickListener(itemClick);
AdapterView.OnItemClickListener itemClick = new AdapterView.OnItemClickListener()
{
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id)
{
switch (parent.getId())
{
case R.id.listview:
expressItemClick(position);//position 代表你点的哪一个
break;
}
}
};
public void expressitemClick(int postion){
Intent intent = new Intent(当前的.class,下一个页面的.class);
startActivity(intent);
finish();//看你需不需要返回当前界面,如果点返回需要返回到当前界面,就不用这个
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |