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");
}
});
Run Code Online (Sandbox Code Playgroud)
类中的getView函数Adapter:
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);
}
}
Run Code Online (Sandbox Code Playgroud)
在充气时使用两个xmls有问题吗?
我正在尝试在ActiveRecord对象上调用一个方法,其中存在同名属性.这会导致SystemStackError: stack level too deep错误.
如何从方法中访问对象属性以进行修改?
def first_name
return self.first_name.upper
end
Run Code Online (Sandbox Code Playgroud)