2013-09-28 40 views
-1

MainActivity.class:如何添加的EditText和按鈕內部的ListView

public class MainActivity extends ListActivity { 

    public static final String TITLE = "title"; 
    public static final String SUBTITLE = "subtitle"; 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
/// setContentView(R.layout.activity_main); 

      setListAdapter(createAdapter()); 
      } 
    protected Map<String, String> createElement(String title, String subtitle) 
    { 
     Map<String, String> result = new HashMap<String, String>(); 

     result.put(TITLE, title); 
     result.put(SUBTITLE, subtitle); 
      return result; 
    } 
    public List<Map<String, String>> getData() 
    { 
     List<Map<String, String>> result = new ArrayList<Map<String,String>>(); 
     result.add(createElement("Hello", "")); 
     result.add(createElement("Hello2", "")); 
     result.add(createElement("Hello3", "")); 

     return result; 
    } 

    public ListAdapter createAdapter() 
    { 
     SimpleAdapter adapter = new SimpleAdapter(this, getData(), 
       android.R.layout.simple_list_item_2, 
       new String[]{TITLE, SUBTITLE, }, 
       new int[]{android.R.id.text1, android.R.id.text2}); 
     adapter.areAllItemsEnabled(); 
     return adapter; 
    } 

    @Override 
    protected void onListItemClick(ListView l, View v, int position, long id) { 
     Intent i = null; 
     switch (position) 
     { 
     case 0: 
      i = new Intent(this, GalleryUrlActivity.class); 
      break; 
     case 1: 
      i = new Intent(this, GalleryFileActivity.class); 
      break; 
     case 2: 
      i = new Intent(this, SonEklenen.class); 
      break; 

     } 
     startActivity(i); 
    } 

} 

如何添加的EditText和按鈕內部的ListView

我想補充MainActivity類別中的按鈕和EditText上。我怎樣才能做到這一點?

回答

相關問題