开发者

Textview , Button and ListView in one layout

开发者 https://www.devze.com 2023-03-14 05:16 出处:网络
I want to create a layout which contains TextView , Button and ListView here is the following ex开发者_运维技巧ample

I want to create a layout which contains TextView , Button and ListView here is the following ex开发者_运维技巧ample

Textview , Button and ListView in one layout

  • Red box contains TextView
  • Green box contains button
  • Blue box contains costumed ListView

I have created a ListView activity now i don't know how to embed it with TextView and Buttons above

Note my ListView inflate the custom layout.


You'll use a LinearLayout with a vertical orientation:

<LinearLayout
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

    <TextView android:layout_height="wrap_content" ... />
    <Button  android:layout_height="wrap_content" ... />
    <ListView android:layout_height="0dp" android:layout_weight="1" ... />

</LinearLayout>

If you want your ListView to stretch to fill the remaining room on the screen, you use the android:layout_weight attribute as above.


you can do my extend Activity also
on you can identify your controls like this

 setContentView(R.layout.yourlayout);  
 TextView textView = (TextView) findViewById(R.id.TextView01);
 Button button= (Button ) findViewById(R.id.Button01);
 ListView listView = (ListView ) findViewById(R.id.ListView01); 

and you can set listView adapter like this

listView.setAdapter(CustomAdapeterClassObject)
0

精彩评论

暂无评论...
验证码 换一张
取 消