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 8610881
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T04:13:57+00:00 2026-06-12T04:13:57+00:00

I used the instructions given Here: http://developer.android.com/guide/topics/ui/dialogs.html#AddingAList to create a List in a dialog.

  • 0

I used the instructions given Here: http://developer.android.com/guide/topics/ui/dialogs.html#AddingAList to create a List in a dialog.

The problem is I don’t seem to find out a way to wrap long text inside the options. [Please see the image below]

Text not wrapping properly

Please tell me how to do the text wrapping. 🙁

I am using the following code:

items= getArrayFromJson(source+"getdetails.php?brand="+bName+"&car="+cName);
        builder = new AlertDialog.Builder(this);
        builder.setTitle("Choose Model");
        builder.setSingleChoiceItems(items, -1, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int item) {
                if(items[item].equals("No Options Available")){
                    dismissDialog(2);
                }
                else{
                    model.setText(items[item]);
                    mName= items[item].toString();

                    location.setEnabled(true);
                    dismissDialog(2);
                }

            }
        });
        alert = builder.create();

        return alert;

Any help/direction is highly appreciated 🙂

  • 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-06-12T04:13:59+00:00Added an answer on June 12, 2026 at 4:13 am

    At first I would create a list layout… something like:

    list_layout

        <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical" >
    
         <ListView
            android:id="@+id/list"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:divider="#b5b5b5"
            android:dividerHeight="1dp" />
     </LinearLayout>
    

    Then a simple TextView like:

    single_item_layout

     <LinearLayout 
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="horizontal" 
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"> 
    
         <TextView android:id="@+id/singleItem"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:gravity="center_vertical"
            android:layout_alignParentTop="true"
            android:layout_alignParentBottom="true"
            android:textStyle="bold"
            android:textSize="22dp"
            android:textColor="#FFFFFF"
            android:padding="10dp"
            android:text="blue thingy"
            android:background="#336699" />
    
    </LinearLayout>
    

    and a simple main layout:

    main

        <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >
    
        <Button
            android:id="@+id/button1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_alignParentLeft="true"
            android:layout_alignParentRight="true"
            android:onClick="popUp"
            android:text="pop dialog list" />
    
    </RelativeLayout>
    

    lastly a simple main Activity:

    import java.util.ArrayList;
    import android.app.Activity;
    import android.app.Dialog;
    import android.os.Bundle;
    import android.view.View;
    import android.widget.AdapterView;
    import android.widget.AdapterView.OnItemClickListener;
    import android.widget.ArrayAdapter;
    import android.widget.ListView;
    
    public class MainActivity extends Activity {
    
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
        }
    
        public void popUp(View v){
    
            // Dummy list:
            ArrayList<String> dummies = new ArrayList<String>();
    
            dummies.add("dumm1");
            dummies.add("dumm2");
            dummies.add("dumm3");
            dummies.add("dumm4");
            dummies.add("dumm5");
    
            final Dialog dialog = new Dialog(MainActivity.this);
            dialog.setContentView(R.layout.list_layout);
            dialog.setTitle("List Title");
            ListView listView = (ListView) dialog.findViewById(R.id.list);
    
            ArrayAdapter<String> ad = new ArrayAdapter<String>(this, R.layout.single_item_layout , R.id.singleItem, dummies);
            listView.setAdapter(ad);
    
            listView.setOnItemClickListener(new OnItemClickListener() {
                @Override
                public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
                    //do something on click
                    dialog.dismiss();
                }
            });
    
            dialog.show();
        }   
    }
    

    and that’s all.

    I tried to make that as simple as possible, you can google for ideas to make your list a bit attractive, like here.

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

Sidebar

Related Questions

i used the examples given in this link here are my code for the
Given a string like this: <a href=http://blah.com/foo/blah>This is the foo link</a> ... and a
I am using open-ssl source given at https://github.com/eighthave/openssl-android to build a library which can
I was told that running programs generate probability data used to optimize repeated instructions.
Used code I found on SO to use the COM based Acrobat Reader to
I used the phonegap website to create an IPA file. Now I want to
I was given this question on my study guide for a test I have
I'm new to HTML and CSS and I tried to create a floating side
Little help here: I am uploading my site following the instructions on this link
I am following the instructions here for cross-compiling GCC. I am on a mac.

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.