각 행에 텍스트와 버튼이있는 목록보기가 있는데 목록보기 setOnItemClickListener ()가 작동하지 않습니다. 항목 클릭과 버튼 클릭 이벤트를 다르게 처리 할 수 있습니까 (항목 클릭은 ActivityA를 호출해야하고 버튼 클릭은 ActivityB를 호출해야 함). 누구든지 해결책이 있습니까
private ArrayList<String> userIDArr = null;
private ArrayList<String> userNameArr = null;
private DatabaseHelper dbHelper = null;
private ListView userListView=null;
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.list_view);
dbHelper = new DatabaseHelper(this.getApplicationContext());
Map<String,ArrayList<String>> displayMap = dbHelper.getUserListToDisplay();
userIDArr = displayMap.get("UserID");
userNameArr = displayMap.get("FirstName1");
userListView = (ListView) findViewById(R.id.listView2);
userListView.setAdapter(new UserListAdapter(this,userIDArr));
userListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) {
Toast.makeText(usersListActivity.this,
"Item in position " + position + " clicked", Toast.LENGTH_LONG).show();
}
});
}
public class UserListAdapter extends ArrayAdapter<String>
{
Activity context;
public UserListAdapter(Activity context, ArrayList<String> names) {
super(context, R.layout.list_item, names);
this.context = context;
}
private class ViewHolder {
public TextView UserNameAndID;
public TextView Description;
public Button UploadBtn;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder;
View rowView = convertView;
if (rowView == null) {
LayoutInflater inflater = context.getLayoutInflater();
rowView = inflater.inflate(R.layout.list_item, null, true);
holder = new ViewHolder();
holder.UserNameAndID = (TextView) rowView.findViewById(R.id.User_detailsTxt);
holder.Description = (TextView) rowView.findViewById(R.id.User_status);
holder.UploadBtn = (Button) rowView.findViewById(R.id.uploadbutton);
holder.UploadBtn.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Toast.makeText(usersListActivity.this," Button clicked",Toast.LENGTH_SHORT).show();
}
});
rowView.setTag(holder);
} else {
holder = (ViewHolder) rowView.getTag();
}
String s = userNameArr.get(position)+","+userIDArr.get(position);
holder.UserNameAndID.setText(s);
holder.Description.setText("U r in middle");
return rowView;
}
}
}`