What's wrong? The last line!

Please very read carefully the documentation for the ArrayAdapter
constructor. You'll need to be sure to understand each word, as it's
rather short on explanation. Given the multiple meanings for 'id',
you'll see how you got confused!

The documentation for the second argument reads:
textViewResourceId      The resource ID for a layout file containing a
TextView to use when instantiating views

That is not what you are providing. You are providing an id of a view,
not a layout file -- and not even the right view.

The id you are supplying here is the ID of the layout that will be
used to display your array elements. For this constructor (with just
the single resource ID), it must be a layout that consists of a single
TextView. The constructors that take two resource IDs let you specify
an arbitrary layout with the first one, and the second one should be
an ID (as in R.id.xxx) of a TextView within that layout.

On Apr 18, 7:35 pm, SheikhAman <[email protected]> wrote:
> Ohk,
> Things went fine, and i was able to design a new layout like this-
> <?xml version="1.0" encoding="utf-8"?>
> <RelativeLayout
> android:id="@+id/widget101"
> android:layout_width="fill_parent"
> android:layout_height="fill_parent"
> xmlns:android="http://schemas.android.com/apk/res/android";
>
>
>
> <RelativeLayout
> android:id="@+id/widget110"
> android:layout_width="fill_parent"
> android:layout_height="wrap_content"
> android:layout_alignParentTop="true"
> android:layout_alignParentLeft="true"
>
> <TextView
> android:id="@+id/widget112"
> android:layout_width="wrap_content"
> android:layout_height="wrap_content"
> android:text="TextView"
> android:layout_centerVertical="true"
> android:layout_centerHorizontal="true"
>
> </TextView>
> <Button
> android:id="@+id/widget111"
> android:layout_width="wrap_content"
> android:layout_height="wrap_content"
> android:text="Button"
> android:layout_alignParentTop="true"
> android:layout_alignParentLeft="true"
>
> </Button>
> <Button
> android:id="@+id/widget113"
> android:layout_width="wrap_content"
> android:layout_height="wrap_content"
> android:text="Button"
> android:layout_alignParentTop="true"
> android:layout_alignParentRight="true"
>
> </Button>
> </RelativeLayout>
> <ListView
> android:id="@+id/widget114"
> android:layout_width="fill_parent"
> android:layout_height="wrap_content"
> android:layout_below="@+id/tweetList"
> android:layout_alignParentLeft="true"
>
> </ListView>
> </RelativeLayout>
>
> Things stay fine until i assign the adapter to the list i have
> created-
>
> public class MainActivity extends Activity {
>     /** Called when the activity is first created. */
>         String[] data={"1","2","3"};
>     @Override
>     public void onCreate(Bundle savedInstanceState) {
>         super.onCreate(savedInstanceState);
>         setContentView(R.layout.main);
>         ListView tweetList = (ListView) findViewById(R.id.tweetList);
>         tweetList.setAdapter(new
> ArrayAdapter<String>(this,R.id.tweetList,data));
>     }
>
> }
>
> as soon as i add the last line, problems start.
>
> whats wrong?
>
> On Apr 19, 6:24 am, SheikhAman <[email protected]> wrote:
>
>
>
>
>
> > ohh, all of the tags didnt have '>' with them.
> > I have already added them but they weren't copied dont know why, so
> > thats not a problem.
>
> > On Apr 19, 6:12 am, SheikhAman <[email protected]> wrote:
>
> > > Oops!
> > > Sorry..
> > > here is the correct one-
>
> > > <?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"
> > >     >
> > > <RelativeLayout
> > > android:id="@+id/widget28"
> > > android:layout_width="wrap_content"
> > > android:layout_height="wrap_content"
> > > android:layout_x="17px"
> > > android:layout_y="10px"
>
> > > <Button
> > > android:id="@+id/widget40"
> > > android:layout_width="wrap_content"
> > > android:layout_height="wrap_content"
> > > android:text="Button"
> > > android:layout_alignTop="@+id/widget39"
> > > android:layout_toRightOf="@+id/widget38"
>
> > > </Button>
> > > <TextView
> > > android:id="@+id/widget39"
> > > android:layout_width="wrap_content"
> > > android:layout_height="wrap_content"
> > > android:text="TextView"
> > > android:layout_alignParentBottom="true"
> > > android:layout_alignParentLeft="true"
> > > </TextView>
>
> > > <Button
> > > android:id="@+id/widget38"
> > > android:layout_width="wrap_content"
> > > android:layout_height="wrap_content"
> > > android:text="Button"
> > > android:layout_alignParentTop="true"
> > > android:layout_alignParentRight="true"
> > > </Button>
>
> > > </RelativeLayout>
> > > <ListView
> > >         android:id="@+id/tweetList"
> > >         android:layout_width="wrap_content"
> > >         android:layout_height="wrap_content"
> > >     />
> > > </LinearLayout>
>
> > > Please tell.
>
> > > On Apr 18, 11:11 pm, Anurag Singh <[email protected]> wrote:
>
> > > > I think, it's not right way.
>
> > > > <TextView
> > > > android:id="@+id/widget39"
> > > > android:layout_width="wrap_
> > > > content"
> > > > android:layout_height="wrap_content"
> > > > android:text="TextView"
> > > > android:layout_alignParentBottom="true"
> > > > android:layout_alignParentLeft="true"
>
> > > > <Button
> > > > android:id="@+id/widget38"
> > > > android:layout_width="wrap_content"
> > > > android:layout_height="wrap_content"
> > > > android:text="Button"
> > > > android:layout_alignParentTop="true"
> > > > android:layout_alignParentRight="true"
>
> > > > </Button>
> > > > </TextView>
> > > >  You have mention Button in a TextView.
>
> > > > - Anurag Singh
>
> > > > Hi. please find the link to attached file, i need to have this kinda
>
> > > > > layout.
> > > > > is it possible??
> > > > > well perhaps it is, but im not getting it how to do it.
> > > > > i want to specify the whole layout in the xml, but it gives runtime
> > > > > error
>
> > > > > here's the link to the blue print of desired layout:
>
> > > > >http://lh6.ggpht.com/_o9EYB0b5APY/S8s-coQE-KI/AAAAAAAACrA/KJUl5ANBi88...
>
> > > > > here's my 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"
>
> > > > > <RelativeLayout
> > > > > android:id="@+id/widget28"
> > > > > android:layout_width="wrap_content"
> > > > > android:layout_height="wrap_content"
> > > > > android:layout_x="17px"
> > > > > android:layout_y="10px"
>
> > > > > <Button
> > > > > android:id="@+id/widget40"
> > > > > android:layout_width="wrap_content"
> > > > > android:layout_height="wrap_content"
> > > > > android:text="Button"
> > > > > android:layout_alignTop="@+id/widget39"
> > > > > android:layout_toRightOf="@+id/widget38"
>
> > > > > </Button>
> > > > > <TextView
> > > > > android:id="@+id/widget39"
> > > > > android:layout_width="wrap_content"
> > > > > android:layout_height="wrap_content"
> > > > > android:text="TextView"
> > > > > android:layout_alignParentBottom="true"
> > > > > android:layout_alignParentLeft="true"
>
> > > > > <Button
> > > > > android:id="@+id/widget38"
> > > > > android:layout_width="wrap_content"
> > > > > android:layout_height="wrap_content"
> > > > > android:text="Button"
> > > > > android:layout_alignParentTop="true"
> > > > > android:layout_alignParentRight="true"
>
> > > > > </Button>
> > > > > </TextView>
> > > > > </RelativeLayout>
> > > > > <ListView
> > > > >        android:id="@+id/tweetList"
> > > > >        android:layout_width="wrap_content"
> > > > >        android:layout_height="wrap_content"
> > > > >    />
> > > > > </LinearLayout>
>
> > > > > is anything wrong??
>
> > > > > --
> > > > > You received this message because you are subscribed to the Google
> > > > > Groups "Android Developers" group.
> > > > > To post to this group, send email to 
> > > > > [email protected]
> > > > > To unsubscribe from this group, send email to
> > > > > [email protected]<android-developers%2Bunsubs
> > > > >  [email protected]>
> > > > > For more options, visit this group at
> > > > >http://groups.google.com/group/android-developers?hl=en
>
> > > > --
> > > > You received this message because you are subscribed to the Google
> > > > Groups "Android Developers" group.
> > > > To post to this group, send email to [email protected]
> > > > To unsubscribe from this group, send email to
> > > > [email protected]
> > > > For more options, visit this group 
> > > > athttp://groups.google.com/group/android-developers?hl=en
>
> > > --
> > > You received this message because you are subscribed to the Google
> > > Groups "Android Developers" group.
> > > To post to this group, send email to [email protected]
> > > To unsubscribe from this group, send email to
> > > [email protected]
> > > For more options, visit this group 
> > > athttp://groups.google.com/group/android-developers?hl=en
>
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Android Developers" group.
> > To post to this group, send email to [email protected]
> > To unsubscribe from this group, send email to
> > [email protected]
> > For more options, visit this group 
> > athttp://groups.google.com/group/android-developers?hl=en
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group 
> athttp://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to