【发布时间】:2011-07-29 21:25:22
【问题描述】:
Activity类代码:
conversationList = (ListView)findViewById(android.R.id.list);
ConversationArrayAdapter conversationArrayAdapter=new ConversationArrayAdapter(this, R.layout.conversation_list_item_format_left, conversationDetails);
conversationList.setAdapter(conversationArrayAdapter);
conversationList.setOnItemClickListener(new AdapterView.OnItemClickListener(){
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) {
Log.d("test","clicked");
}
});
Adapter 类中的getView 函数:
if (v == null) {
LayoutInflater vi = (LayoutInflater)ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
if(leftSideMessageNumber.equals(m.getTo())) {
v = vi.inflate(R.layout.conversation_list_item_format_left, null);
} else {
v = vi.inflate(R.layout.conversation_list_item_format_right, null);
}
}
inflating时使用两个xml有问题吗?
【问题讨论】:
-
@hiei 我的问题是我在布局单元格中使用了图像按钮。即使添加了“android:descendantFocusability”,我的点击监听器也没有响应。我所做的是,我将所有 ImaegButtons 更改为 ImageViews。这解决了我的问题。