活动类的继承人的code
heres the code of activity class
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");
}
});
继承人的$ C $ getView功能从适配器C类
heres the code of getView function from adapter class
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);
}
}
有没有使用2 XMLS而膨胀的问题... 所有帮助是AP preciated ....
Is there a problem for using 2 xmls while inflating... all help is appreciated....
我刚刚发现从这里的解决方案。但深点击...
I just found solution from here.. but by deep clicking...
如果列表中的任何行项目包含可成为焦点或点击视图,则 OnItemClickListener
将无法正常工作。
If any row item of list contains focusable or clickable view then OnItemClickListener
won't work.
行项目必须有一个像参数机器人:descendantFocusability =blocksDescendants
The row item must have a param like android:descendantFocusability="blocksDescendants"
.
在这里你可以看到的例子,你是如何列表项应该是什么样子。 您的列表项的XML应该是... row_item.xml(your_xml_file.xml)
here you can see example, how your list item should look like. Your list item xml should be... row_item.xml (your_xml_file.xml)
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:baselineAligned="false"
android:descendantFocusability="blocksDescendants"
android:gravity="center_vertical" >
// your other widgets here
</LinearLayout>