Textview , Button and ListView in one layout
I want to create a layout which contains TextView , Button and ListView here is the following ex开发者_运维技巧ample
- 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)
精彩评论