很遗憾,我的应用在加载此活动时崩溃了:
public class ManagerActivity extends Activity implements OnClickListener {
private TabHost th;
private EditText addpray1;
private EditText addplace1;
private EditText addtime1;
private Button addpray1Button;
private EditText removepray1;
private EditText removeplace1;
private EditText removetime1;
private Button removepray1Button;
private EditText addpray2;
private EditText addplace2;
private EditText addtime2;
private Button addpray2Button;
private EditText removepray2;
private EditText removeplace2;
private EditText removetime2;
private Button removepray2Button;
private EditText addtitlemessage;
private EditText addinfomessage;
private Button addmessagebutton;
private EditText removetitlemessage;
private Button removemessagebutton;
private EditText addtitleevent;
private EditText addinfoevent;
private Button addeventbutton;
private EditText removetitleevent;
private Button removeeventbutton;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.manager);
th = (TabHost) findViewById(R.id.tabhost);
InitTabs(th);
InitFields();
addpray1Button.setOnClickListener(this);
removepray1Button.setOnClickListener(this);
addpray2Button.setOnClickListener(this);
removepray2Button.setOnClickListener(this);
addeventbutton.setOnClickListener(this);
removeeventbutton.setOnClickListener(this);
addmessagebutton.setOnClickListener(this);
removeeventbutton.setOnClickListener(this);
}
private void InitTabs(TabHost th){
th.setup();
TabSpec specs = th.newTabSpec("tag1");
specs.setContent(R.id.tab1);
specs.setIndicator("עדכון הודעות");
th.addTab(specs);
specs = th.newTabSpec("tag2");
specs.setContent(R.id.tab2);
specs.setIndicator("עדכון אירועים");
th.addTab(specs);
specs = th.newTabSpec("tag3");
specs.setContent(R.id.tab3);
specs.setIndicator("עדכון זמני השבת");
th.addTab(specs);
specs = th.newTabSpec("tag3");
specs.setContent(R.id.tab4);
specs.setIndicator("עדכון זמני יום חול");
th.addTab(specs);
}
private void InitFields() {
// TODO Auto-generated method stub
addpray1 = (EditText) findViewById(R.id.addPray1);
addplace1 = (EditText) findViewById(R.id.place1);
addtime1 = (EditText) findViewById(R.id.time1);
addpray1Button = (Button) findViewById(R.id.addPrayButton1);
removepray1 = (EditText) findViewById(R.id.removePray1);
removeplace1 = (EditText) findViewById(R.id.time_remove1);
removetime1 = (EditText) findViewById(R.id.place_remove1);
removepray1Button = (Button) findViewById(R.id.removePrayButton1);
addpray2 = (EditText) findViewById(R.id.pray2);
addplace2 = (EditText) findViewById(R.id.place2);
addtime2 = (EditText) findViewById(R.id.time2);
addpray2Button = (Button) findViewById(R.id.addPrayButton2);
removepray2 = (EditText) findViewById(R.id.removePray2);
removeplace2 = (EditText) findViewById(R.id.place_remove2);
removetime2 = (EditText) findViewById(R.id.time_remove2);
removepray2Button = (Button) findViewById(R.id.removePrayButton2);
addtitlemessage = (EditText) findViewById(R.id.titleMessage);
addinfomessage = (EditText) findViewById(R.id.messageInfo);
addmessagebutton = (Button) findViewById(R.id.addMessageButton);
removetitlemessage = (EditText) findViewById(R.id.removeMessage);
removemessagebutton = (Button) findViewById(R.id.removeMessageButton);
addtitleevent = (EditText) findViewById(R.id.addEvent);
addinfoevent = (EditText) findViewById(R.id.eventInfo);
addeventbutton = (Button) findViewById(R.id.addEventButton);
removetitleevent = (EditText) findViewById(R.id.removeEvent);
removeeventbutton = (Button) findViewById(R.id.removeEventButton);
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
}
}
和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" >
<ProgressBar
android:id="@+id/progressbar"
style="@android:style/Widget.ProgressBar.Horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TabHost
android:id="@+id/tabhost"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TabWidget
android:id="@android:id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</TabWidget>
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:id="@+id/tab1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="2" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1" >
<TextView
android:id="@+id/addMessage"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:text="הוספת הודעה"
android:textSize="25sp" />
<EditText
android:id="@+id/titleMessage"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/addMessage"
android:hint="כותרת"
android:lines="1"
android:scrollHorizontally="false" />
<EditText
android:id="@+id/messageInfo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/titleMessage"
android:hint="מידע"
android:lines="4"
android:scrollHorizontally="true" />
<Button
android:id="@+id/addMessageButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/messageInfo"
android:layout_centerInParent="true"
android:text="הוסף" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1" >
<TextView
android:id="@+id/removeMessage"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:text="הסרת הודעה"
android:textSize="25sp" />
<EditText
android:id="@+id/titleMessage_remove"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/removeMessage"
android:hint="כותרת"
android:lines="1"
android:scrollHorizontally="false" />
<Button
android:id="@+id/removeMessageButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/titleMessage_remove"
android:layout_centerInParent="true"
android:text="הסר" />
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/tab2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="2" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1" >
<TextView
android:id="@+id/addEvent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:text="הוספת אירוע"
android:textSize="25sp" />
<EditText
android:id="@+id/titleEvent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/addEvent"
android:hint="כותרת"
android:lines="1"
android:scrollHorizontally="false" />
<EditText
android:id="@+id/eventInfo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/titleEvent"
android:hint="מידע"
android:lines="4"
android:scrollHorizontally="true" />
<Button
android:id="@+id/addEventButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/eventInfo"
android:layout_centerInParent="true"
android:text="הוסף" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1" >
<TextView
android:id="@+id/removeEvent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:text="הסרת אירוע"
android:textSize="25sp" />
<EditText
android:id="@+id/titleEvent_remove"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/removeEvent"
android:hint="כותרת"
android:lines="1"
android:scrollHorizontally="false" />
<Button
android:id="@+id/removeEventButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/titleEvent_remove"
android:layout_centerInParent="true"
android:text="הסר" />
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/tab3"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="2" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1" >
<TextView
android:id="@+id/addPray1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:text="הוספת תפילה"
android:textSize="25sp" />
<EditText
android:id="@+id/pray1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/addPray1"
android:hint="תפילה" />
<EditText
android:id="@+id/place1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/pray1"
android:hint="מקום" />
<EditText
android:id="@+id/time1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/place1"
android:hint="שעה" />
<Button
android:id="@+id/addPrayButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/time1"
android:layout_centerInParent="true"
android:text="הוסף" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1" >
<TextView
android:id="@+id/removePray1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:text="הסרת תפילה"
android:textSize="25sp" />
<EditText
android:id="@+id/pray_remove1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/removePray1"
android:hint="תפילה" />
<EditText
android:id="@+id/place_remove1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/pray_remove1"
android:hint="מקום" />
<EditText
android:id="@+id/time_remove1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/place_remove1"
android:hint="שעה" />
<Button
android:id="@+id/removePrayButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/time_remove1"
android:layout_centerInParent="true"
android:text="הסר" />
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/tab4"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="2" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1" >
<TextView
android:id="@+id/addPray2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:text="הוספת תפילה"
android:textSize="25sp" />
<EditText
android:id="@+id/pray2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/addPray2"
android:hint="תפילה" />
<EditText
android:id="@+id/place2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/pray2"
android:hint="מקום" />
<EditText
android:id="@+id/time2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/place2"
android:hint="שעה" />
<Button
android:id="@+id/addPrayButton2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/time2"
android:layout_centerInParent="true"
android:text="הוסף" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1" >
<TextView
android:id="@+id/removePray2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:text="הסרת תפילה"
android:textSize="25sp" />
<EditText
android:id="@+id/pray_remove2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/removePray2"
android:hint="תפילה" />
<EditText
android:id="@+id/place_remove2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/pray_remove2"
android:hint="מקום" />
<EditText
android:id="@+id/time_remove2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/place_remove2"
android:hint="שעה" />
<Button
android:id="@+id/removePrayButton2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/time_remove2"
android:layout_centerInParent="true"
android:text="הסר" />
</RelativeLayout>
</LinearLayout>
</FrameLayout>
</LinearLayout>
</TabHost>
</LinearLayout>
我想这是因为我加载了很多观点......
我还想添加一个在布局加载时有效的进度条,直到完成为止。
我该如何解决?
谢谢:)