Skip to content Skip to sidebar Skip to footer

Listview Adding Spinner In Each Row?

I am facing problem while putting Spinner in layout. My acctual requirement is to place Spinner once, at the top of layout. This output I am getting: I have Relative layout &

Solution 1:

Here is the code in which spinner inflates on the top of listview :

listView= (ListView) findViewById(R.id.list);

        LayoutInflaterinflater= LayoutInflater.from(this);
        ViewmTop= inflater.inflate(R.layout.spin, null);
        authorityView.addHeaderView(mTop);

R.layout.spin is that layout which contains only spinner. And inside the List you have to inflate textView only. as you are doing in mylist.xml , just remove spinner from it and made seprate xml for spinner.

so spinner is once, at the top of layout (ListView).

Solution 2:

I have some difficulty making out what your actual question is, some layout.xml code would help here, too. I think, that you are placing the spinner inside the listitem.xml instead of the main.xml, so that it gets replicated for each item in your listview. Please share some code. Since you declare both the TextView and the Spinner in mylist.xml, you get both those elements in each Item of your List. If you only want one spinner, you shouldn't use a ListActivity, but instead create a normal Activity with a Spinner and a ListView in the Layout. Then define another layout to use for the list items (e.g. with only the TextView).

Post a Comment for "Listview Adding Spinner In Each Row?"