LinearLayout for ListAdapter : LinearLayout « UI « Android

Home
Android
1.2D Graphics
2.Animation
3.Core Class
4.Database
5.Date Type
6.Development
7.File
8.Game
9.Hardware
10.Media
11.Network
12.Security
13.UI
14.User Event
Android » UI » LinearLayout 
LinearLayout for ListAdapter
   

package app.test;

import android.app.ListActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class Test extends ListActivity {
  private String[] data = {};

  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    setListAdapter(new ArrayAdapter<String>(this,
        android.R.layout.simple_list_item_1, data));
  }

  protected void onListItemClick(ListView listView, View v, int position,
      long id) {
    super.onListItemClick(listView, v, position, id);
    setTitle(listView.getItemAtPosition(position).toString());
  }
}



//main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="wrap_content"
    android:layout_height="wrap_content">
  <ListView android:id="@id/android:list"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"/>
    <TextView android:id="@id/android:empty"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Empty"/>      
</LinearLayout>

   
    
    
  
Related examples in the same category
1.Adding two controls to LinearLayout
2.Using LinearLayout for Activity
3.Using LinearLayout to layout two RadioGroups
4.Using LinearLayout.LayoutParams
5.Using LinearLayout
6.LinearLayout which uses a combination of wrap_content on itself and match_parent on its children to get every item to be the same width.
7.LinearLayout inside ScrollView
8.Transparent Panel extends LinearLayout
9.Set min height
10.Set padding right
11.Set padding with dpi value
12.Baseline alignment includes a android.widget.LinearLayout within another android.widget.LinearLayout.
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.