Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7661629
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:37:24+00:00 2026-05-31T13:37:24+00:00

PS: the reference link www.­androidpeople.­com/­android-­custom-­listview-­tutorial-­part-­1 is not available. Dears, I am trying to create

  • 0

PS: the reference link ” http://www.­androidpeople.­com/­android-­custom-­listview-­tutorial-­part-­1″ is not available.

Dears, I am trying to create a single choice ListView accompany with mutilple items list on Android by using the below code (1 java main program and 2 xml layout files). However it will shows multiple radiobuttons enabled, this is not my expection, they should be mutually exclusive !

And How to get the position/content(?) of the choiced listview ?

Could you help me review where I was wrong and how to implement it ? Thanks a lot for the Help !

My code lists:
main java code:

package list.view;
import android.app.Activity;
import android.os.Bundle;
import android.widget.ListView;
import android.widget.RadioButton;
import android.widget.SimpleAdapter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

public class MultipleItemsListView extends Activity 
{
    private ListView mListView01;
    private SimpleAdapter mSimpleAdapter;
    private List<String> allTxt1;
    private List<String> allTxt2;
    private List<String> allTxt3;  
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        mListView01 = (ListView)this.findViewById(R.id.listView1);        
        updateListView();
    }   

    private void updateListView()
    {      
      allTxt1 = new ArrayList<String>();
      allTxt2 = new ArrayList<String>();
      allTxt3 = new ArrayList<String>();      

      for (int i = 0 ; i<5; i++)
      {
        allTxt1.add("test1"+i);
        allTxt2.add("test2"+i);
        allTxt3.add("test3"+i);        
      }

      if(allTxt1.size()>0)
      {
        ArrayList<HashMap<String, String>> mylist = new ArrayList<HashMap<String, String>>();
        HashMap<String, String> map;
        for (int i = 0; i< allTxt1.size(); i++)
        {
          map = new HashMap<String, String>();
          map.put("txt1", allTxt1.get(i));
          map.put("txt2", allTxt2.get(i));
          map.put("txt3", allTxt3.get(i));                
          mylist.add(map);
        }

        mSimpleAdapter = new SimpleAdapter
        (
            this, mylist, R.layout.items_list  ,
            new String[] {"txt1", "txt2", "txt3",""},
            new int[] {R.id.textView1,  R.id.textView2 , R.id.textView3 ,R.id.radioButton1}
        );
        mListView01.setItemsCanFocus(true);
      //  mListView01.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
        mListView01.setAdapter(mSimpleAdapter);      
      }      
    }
}

Layout1:
main.xml

<TextView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="@string/hello" />
  <RadioGroup
    android:id="@+id/radioGroup1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" >    

<ListView
    android:id="@+id/listView1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >
</ListView>  </RadioGroup> </LinearLayout>

Layout2:
items_list.xml

<TextView
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:padding="3dip"
    android:text="TextView1" />

<TextView
    android:id="@+id/textView2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
     android:padding="3dip"
    android:text="TextView2" />

<TextView
    android:id="@+id/textView3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
     android:padding="3dip"
    android:text="TextView3" />

<RadioButton
    android:id="@+id/radioButton1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginRight="10dip"/> </LinearLayout>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T13:37:25+00:00Added an answer on May 31, 2026 at 1:37 pm

    It seems hard to get the solution/response from our friends. And I had to let progress to go.
    So, I used an alternative to cover this question/problem, and I would like share it below:

    I combinded every list items’ description(text String) to One String first. And then, implements the “simple_list_item_single_choice.xml” with this String to build the ListView.

    To use this way there are some limitation for my applicaiton, is not the best way for me (only 60% meet my expection.). Hope there is correct method responsed !

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So according to the link here: http://www.cplusplus.com/reference/algorithm/max_element/ , the max_element function is O(n), apparently
http://www.plus2net.com/php_tutorial/array_checkbox.php the link is my reference in PHP i want to ask how can
http://www.cplusplus.com/reference/algorithm/make_heap/ In this link. it says: Internally, a heap is a tree where each
I have the following link: http://www.europarl.europa.eu/sides/getDoc.do?type=REPORT&mode=XML&reference=A7-2010-0001&language=EN the reference part of the url has the
Reference Link: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2849.pdf I am trying to gather information about TR2 and how it
I am following an intro tutorial http://www.linuxinsight.com/files/alp/alp-ch01-getting-started.pdf . I have created the source files
I've been trying to use the Like button generated here: https://developers.facebook.com/docs/reference/plugins/like/ But so far,
i can reference link with specific id with following code $(document).ready(function(){ $(a#example_link_id).click(function(event){ var url
With reference to the following link: http://docs.python.org/faq/library.html#what-kinds-of-global-value-mutation-are-thread-safe I wanted to know if the following:
Does anyone know of a link to a reference on the web that contains

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.