Activity 設定介面時 - Android

By Annie
at 2014-07-23T17:42
at 2014-07-23T17:42
Table of Contents
我使用的開發環境是 google 開發網站的 Bundle Eclips ADT
@SuppressLint({ "InlinedApi", "NewApi" }) public class Ch5_5_6Activity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//setContentView(R.layout.activity_ch5_5_6);
TextView lb101= new TextView(this);
lb101.setText("XXX");
lb101.setTextSize(20);
lb101.setGravity(Gravity.CENTER);
TextView lb102= new TextView(this);
lb102.setText("XXX2");
lb102.setTextSize(20);
lb102.setGravity(Gravity.LEFT);
//建立 LinearLayout 物件
LinearLayout ll=new LinearLayout(this);
//指定版面配置的方向和寬和高
ll.setOrientation(LinearLayout.VERTICAL);
ll.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
LayoutParams.FILL_PARENT));
ll.addView(lb101);
ll.addView(lb102);
setContentView(ll);
if (savedInstanceState == null) {
getSupportFragmentManager().beginTransaction()
.add(R.id.container, new PlaceholderFragment())
.commit();
}
}
run as application ,要跳出activity時出現此activity stop的訊息,我看了
程式碼,是在一開始的setContentView(R.layout.activity_ch5_5_6)出了錯誤
因為我把它註解掉了,可是我後面有設定 setContentView(ll);阿,整個範例
是照著課本打的,請問我這哪邊有錯誤阿..?謝謝。
--
Tags:
Android
All Comments

By Madame
at 2014-07-27T06:20
at 2014-07-27T06:20

By Margaret
at 2014-07-31T04:20
at 2014-07-31T04:20

By Lydia
at 2014-08-04T09:27
at 2014-08-04T09:27

By Oliver
at 2014-08-06T05:25
at 2014-08-06T05:25

By Hardy
at 2014-08-08T20:14
at 2014-08-08T20:14

By John
at 2014-08-13T06:20
at 2014-08-13T06:20

By Mia
at 2014-08-17T08:54
at 2014-08-17T08:54
Related Posts
影片合併App

By Rachel
at 2014-07-23T17:40
at 2014-07-23T17:40
HTC 816 如何選取多個相片刪除?

By Blanche
at 2014-07-23T16:38
at 2014-07-23T16:38
刷官方recovery後無法充電

By Zenobia
at 2014-07-23T15:50
at 2014-07-23T15:50
請推薦行事曆app

By Zanna
at 2014-07-23T15:02
at 2014-07-23T15:02
3G版蝴蝶S Sense6.0的OTA包

By Necoo
at 2014-07-23T15:02
at 2014-07-23T15:02