1. Check out our companion app, Forums for Android! Download from Google Play

How to display ListView and EditText Box?

Discussion in 'Application Development' started by madtroll, Oct 18, 2010.

  1. madtroll

    madtroll New Member
    Thread Starter
    5

    Oct 18, 2010
    1
    0
    5
    I want to display EditText box and ListView together.

    I found many tutorials how display them separately, but i stuck trying display them together.

    This is my code:

    public class myApp extends Activity
    {

    public​
    void onCreate(Bundle savedInstanceState)
    {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.
    main);

    myEditBox = (EditText) findViewById(R.id.entry);

    ArrayAdapter<String> MyAdapter = ​
    new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,myArray);
    ListView myListViev =
    new ListView(this);
    myListViev .setAdapter(MyAdapter );

    }
    }

    But this code display only EditText box, but it not display an array.
    How i can fix my code to display my array as well.

     

    Advertisement

  2. subirdas@rjs.in

    subirdas@rjs.in New Member
    5

    Oct 20, 2010
    1
    0
    5
    please add an xml file in layout folder and then write:
    ArrayAdapter<String> MyAdapter = ​
    new ArrayAdapter<String>(this,R.layout.newxml,myArray);

    newxml.xml would be like:

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_height="410px" android:gravity="left|center"
    android:layout_width="300px" android:paddingBottom="5px"
    android:paddingTop="5px" android:paddingLeft="5px" android:background="@layout/corner">
    <TextView android:id="@+id/TextView01" android:layout_width="wrap_content"
    android:layout_height="wrap_content" android:gravity="center"
    android:background="@drawable/action_blue_button" android:textColor="#FFFF00" android:textSize="12px"
    android:fadingEdge="none" android:textColorHint="#FFFFFF"
    ></TextView>
    <TextView android:text="@+id/TextView02" android:id="@+id/TextView02"
    android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="12px"
    android:layout_marginLeft="10px" android:textColor="#0099CC" android:fadingEdge="none" android:textColorHint="#FFFFFF"
    ></TextView>
    </LinearLayout>
     
  3. Sam Voss

    Sam Voss Well-Known Member
    43

    Jun 25, 2010
    367
    44
    43
    Programmer, in school
    Wisconsin
    okay, So I kinda understand where you're both coming from.. and from now on, please post you're codes in "code boxes" alright? thanks.

    and moving on to the question. From what I'm seeing, We really will have to see your main.xml please. just switch to the xml tab at the bottom, and copy/paste into your comment INSIDE the codeview. sorry I cant be of more help at the moment
     

Share This Page

Loading...