我只是堅持這個問題,我想要做的是主要活動首先檢查保存在不同的活動上的偏好,然後繼續setContentView()
等。主要活動項目不會顯示
註冊活動正常,但是當這個活動想要回到主要活動。主Activity不會顯示ListView,Buttons等,只是操作欄是可見的。
我不確定問題出在哪裏,有人可以幫助我解決這個問題。
MainActivity.Java
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
/**
* default values.
*/
if (Settings.isRegistered(this)) {
Intent i = new Intent(this, Register.class);
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
this.startActivity(i);
return;
}
setContentView(R.layout.Msg);
messageList = (ListView) findViewById(R.id.message_list);
.
.
.
}
Msg.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<EditText
android:id="@+id/message_text"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_weight="0.7"
android:hint="@string/message_edit_text"
android:inputType="text"
android:textAppearance="?android:attr/textAppearanceMedium" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<EditText
android:id="@+id/chatroom"
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_weight="0.7"
android:hint="@string/chatroom_text"
android:inputType="text"
android:textAppearance="?android:attr/textAppearanceMedium"/>
<Button
android:id="@+id/send_button"
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_weight="0.3"
android:text="@string/sendlabel"
android:textAppearance="?android:attr/textAppearanceMedium"/>
</LinearLayout>
<ListView
android:id="@+id/messagelist"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:stackFromBottom="true"
android:transcriptMode="alwaysScroll" >
</ListView>
</LinearLayout>
謝謝!......................... –