listview - Android Simple ToDo list app not rendering correctly -


am following tutorial here on creating simple todo list app: http://www.mydroid.apnafundaz.com/2010/07/todolist-application-in-android-step-by-step-guide-with-screen-shots/

have completed , have no errors, app doesn't appear in example, rather looks - edittext appears, there's no listview previous tasks...

as there's no errors, it's rather hard work out i'm going wrong, partner's doing same tutorial , has come same result, thinking there issue tut - advice appreciated!

just in case, here's java file:

package com.example.helloworld;  import java.util.arraylist; import android.r.string; import android.app.activity; import android.os.bundle; import android.view.keyevent; import android.view.view; import android.view.view.onkeylistener; import android.widget.arrayadapter; import android.widget.edittext; import android.widget.listview;  public class helloworld extends activity { /** called when activity first created. */ @override public void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);      // inflate view     setcontentview(r.layout.main);      // references ui widgets     listview mylistview = (listview)findviewbyid(r.id.mylistview);     final edittext myedittext = (edittext)findviewbyid(r.id.myedittext);      // create array list of todo items     final arraylist<string> todoitems = new arraylist<string>();      // create array adaptor bind array listview     final arrayadapter<string> aa;      aa = new arrayadapter<string>(this,                   android.r.layout.simple_list_item_1,               todoitems);      // bind array adapter listview     mylistview.setadapter(aa);      myedittext.setonkeylistener(new onkeylistener(){       public boolean onkey(view v, int keycode, keyevent event){       if(event.getaction() == keyevent.action_down)        if(keycode == keyevent.keycode_dpad_center)        {         todoitems.add(0,myedittext.gettext().tostring());         aa.notifydatasetchanged();         myedittext.settext("");         return true;        }       return false;      }       }        );    } } 

and here's main.xml:

<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <edittext  android:id="@+id/myedittext"  android:layout_width="fill_parent"  android:layout_height="fill_parent"  android:text="new item"     />     <listview  android:id="@+id/mylistview"  android:layout_width="fill_parent"  android:layout_height="wrap_content"     />     </linearlayout> 

do 1 small change, in edittext setting android:layout_height="fill_parent". cannot see list view. change wrap_content

<edittext  android:id="@+id/myedittext"  android:layout_width="fill_parent"  android:layout_height="wrap_content"  android:text="new item"     /> 

Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -