今天早上,我遇到了一些关于 Eclipse 的问题,以及它的常见错误,即 R 无法重新生成。在我解决它之后,我写了很多新的包,所以恢复到最后一个工作提交不是一个选项,我现在是 17:00...
这是我的代码:
@Override
protected void onCreate(Bundle savedInstanceState) {
mActivity = this;
super.onCreate(savedInstanceState);
contentView = getLayoutInflater().inflate(R.layout.android_messenger_conversation, null);
setContentView(contentView);
}
@Override
protected void onStart() {
super.onStart();
Bundle extras = getIntent().getExtras();
if(extras != null){
Log.i("ConversationActivity/onStart","extras is not null");
String extra = extras.getString(MainActivity.CONVERSATION_EXTRA);
Log.i("ConversationActivity/onStart","got extra gave value: "+extra);
if(extra!=withWhoWeAreChatting){
withWhoWeAreChatting = extra;
}
ArrayList<ConversationInfo> arrayList = Conversation.getConversationWith(getApplicationContext(), extra);
contentView = getLayoutInflater().inflate(R.layout.android_messenger_conversation, null);
LinearLayout linearLayout = (LinearLayout) contentView.findViewById(R.id.android_messgener_conversation_LinearLayout);
for(int i = arrayList.size()-1 ; i >= 0 ; i--){
Log.i("ConversationActivity/onStart","Doing for loop: "+i);
ConversationInfo conversationInfo = arrayList.get(i);
if(conversationInfo.getProtocol()!=null){
RelativeLayout relativeLayout = (RelativeLayout) getLayoutInflater().inflate(R.layout.android_messenger_inbox_message, null);
TextView inbox_message = (TextView)relativeLayout.findViewById(R.id.inbox_message);
inbox_message.setText(conversationInfo.getBody());
linearLayout.addView(relativeLayout);
}
else{
RelativeLayout relativeLayout = (RelativeLayout) getLayoutInflater().inflate(R.layout.android_messenger_sent_message, null);
TextView inbox_message = (TextView)relativeLayout.findViewById(R.id.sentMessage);
inbox_message.setText(conversationInfo.getBody());
linearLayout.addView(relativeLayout);
}
}
setContentView(contentView);
}
}
setContentView(contentView) 就在我的评论上方,并没有改变任何东西。通过日志,我检查了循环内的所有内容都没有错误地执行。
有任何想法吗?
如果你住在欧洲,我可以邮寄给你一些波兰啤酒 :)
干杯