更新时间:2023-01-13 14:59:50
试试这个
listView.setOnItemClickListener(新AdapterView.OnItemClickListener(){ 公共无效onItemClick(适配器视图<>为arg0,ARG1查看,
最终诠释ARG2,长ARG3){ 最后ProgressDialog进度= ProgressDialog.show(
VechiclesDetails.this,,loadingString); progressBar.setIndeterminate(真);
progressBar.setIndeterminateDrawable(getResources()
.getDrawable(R.anim.progressbar_handler));
新主题(新的Runnable接口(){ 公共无效的run(){
尝试{
意图carDetail =新意图(
Details.this,
Screen.class);
carDetail.putExtra(指数,ARG2);
carDetail.putExtra(sellerId,SellerId);
startActivity(carDetail);
progressBar.dismiss();
}赶上(例外五){
progressBar.dismiss();
}
}
})。开始(); }
});
I have created a custom listview
using SimpleAdapter
and in each row of list view i put a button has single id.
I want to get the position
of each row to pass the button but i have a single button id for each row and I want when I click on button it find the position of row and start another activity
please help me
public void click(View v){
//RelativeLayout navi = (RelativeLayout)findViewById(R.layout.custom_row_view);
TextView tv = (TextView)findViewById(R.id.text1);
ImageButton im = (ImageButton)findViewById(R.id.imageButton1);
ListView lv=(ListView)findViewById(android.R.id.list);
int position = 0;
Long id=Long.parseLong((String) adapter.getItem(position));
Intent i=null;
switch(position){
case 1:
i=new Intent(this, ButtonActivity.class);
startActivity(i);
break;
case 2:
i = new Intent(this, PickerActivity.class);
startActivity(i);
break;
}
try this
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> arg0, View arg1,
final int arg2, long arg3) {
final ProgressDialog progressBar = ProgressDialog.show(
VechiclesDetails.this, "", loadingString);
progressBar.setIndeterminate(true);
progressBar.setIndeterminateDrawable(getResources()
.getDrawable(R.anim.progressbar_handler));
new Thread(new Runnable() {
public void run() {
try {
Intent carDetail = new Intent(
Details.this,
Screen.class);
carDetail.putExtra("index", arg2);
carDetail.putExtra("sellerId", SellerId);
startActivity(carDetail);
progressBar.dismiss();
} catch (Exception e) {
progressBar.dismiss();
}
}
}).start();
}
});