我正在开发聊天应用程序。我能够正常发送和接收消息。但是当我尝试整合泡沫消息时,我需要指导。我有2个布局
示例代码如下:
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = getLayoutInflater();
View row = null;
String jid = null;
String even_color, odd_color;
SharedPreferences prefList = getSharedPreferences("PrefsFile",
MODE_PRIVATE);
even_color = prefList.getString("even_bubble_color", "pink");
odd_color = prefList.getString("odd_bubble_color", "green");
int even_color_id = getResources().getIdentifier(even_color,
"drawable", "com.teks.chilltwit"), odd_color_id = getResources()
.getIdentifier(odd_color, "drawable", "com.teks.chilltwit");
//ImageView even_view, odd_view;
// System.out.println("Timeline: Position: "+position+", Length: "+data.length);
// if(position!=data.length-1){
if (jid != null) {
row = inflater.inflate(R.layout.list_row_layout_odd, parent,
false);
TextView textLabel = (TextView) row.findViewById(R.id.text);
textLabel.setText(datav);
}
else {
row = inflater.inflate(R.layout.list_row_layout_even, parent,
false);
TextView textLabel = (TextView) row.findViewById(R.id.text);
textLabel.setText("" + messages);
}
return row;
}
}
在上面的代码中,如果我发送消息,我需要显示左侧布局,否则如果我收到消息,我需要显示正确的布局。请指导我这个问题。
感谢。
答案 0 :(得分:0)
所以,这里的问题是jid总是不为空?