• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps How to display ListView and EditText Box?

madtroll

Lurker
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.

 
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>
 
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
 
Back
Top Bottom