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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:43:25+00:00 2026-05-25T12:43:25+00:00

i m displaying a listview with two textviews .the first textview is used for

  • 0

i m displaying a listview with two textviews .the first textview is used for displaying the name of the location and the second one is for displaying address. i anm retrieving values from database and adding those values in an arraylist. i used a custom arrayadapter class named myadapter inflated the two textviews there but when i set the textviewresourse id of one of the textview i get both the values in a single textview. i want them in sepetate textviews. here is my code in display activity in which i am adding values in an arraylist

c.move(3);
            //  x1=c.getColumnIndex("_id");
            //    y1=c.getColumnIndex("latitude");
            //    z1=c.getColumnIndex("longiitude");
            //    w1=c.getColumnIndex("address");
              x = c.getColumnName(0);
              y = c.getColumnName(1);
              z = c.getColumnName(2);
              w = c.getColumnName(3);
              n=c.getColumnName(4);

     // tv_id.setText(x.toString().toUpperCase());
            //tv_lat.setText(y.toString().toUpperCase());
            //tv_lon.setText(z.toString().toUpperCase());
            // tv_add.setText(w.toString().toUpperCase());
            if(c.moveToFirst())
            {
        do  
        {
                 a = c.getInt(0);
                 b1 = c.getDouble(1);
                 c1 = c.getDouble(2);
                 e = c.getString(3);            
                 f=c.getString(4);

                 results.add(e+"\n"+f);

            }  
            while (c.moveToNext()); }

            Myadapter adapter=new Myadapter(this, R.layout.row,R.id.text2, results);


            lv.setBackgroundColor(Color.WHITE);
            //lv.setTextFilterEnabled(true);
            lv.setCacheColorHint(Color.WHITE);
                lv.setAdapter(adapter);

here R.id.text2 is id of the second textview.
here is my code in myadapter class

public Myadapter(Context context, int resource, int textViewResourceId,
            List<String> results) {
        super(context, resource, textViewResourceId, results);
        // TODO Auto-generated constructor stub
        this.context=context;
        this.results=results;

    }

    private List<String> results;
Context context;




    private static final String LayoutInflater = null;

@Override
     public View getView(final int position, View convertView, ViewGroup viewGroup) {
          String name=results.get(position);
          String address=results.get(position);
            if (convertView == null) {
                 LayoutInflater inflater = (LayoutInflater) context
                 .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                convertView = inflater.inflate(R.layout.row, null);
            }
            TextView tv11 = (TextView) convertView.findViewById(R.id.text11);
            tv11.setText(name);

            TextView text2 = (TextView) convertView.findViewById(R.id.text2);
            text2.setText(address);
    pls help me. here is the row.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"

    >



    <TextView
        android:id="@+id/text11"

        android:layout_alignParentLeft="true"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
  android:textSize="20sp"
  android:textColor="#000000"
         />


          <TextView
        android:id="@+id/text2"

        android:layout_alignParentLeft="true"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
  android:textSize="10sp"
    android:textColor="#000000"
         />

          <Button android:text="Delete" android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:focusable="false" android:focusableInTouchMode="false" 
          ></Button>
</LinearLayout>

pls help me i want name to appear in first textview and address in the second. pls help me. thanks and regards

  • 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-25T12:43:26+00:00Added an answer on May 25, 2026 at 12:43 pm

    change your layout

        android:id="@+id/text2"
    
        android:layout_alignParentRight="true"
    

    in your second text view. you have aligned both textviews to left. change the alignment of the second textview as mentioned above. but still you will encounter overlapping if one of the text is huge.

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

Sidebar

Related Questions

I have two activities one displaying map view and another listview, the main objective
I have list with items having two textview and one imageview.I inflate the list
i have a problem with displaying listview. i have tabbed activity and one of
Following shows the code and screenshot for displaying data in listview containing 3 textview
I have a activity displaying call logs in a ListView. The adapter used here
I am trying to implement a ListView data control for displaying and editing lookup
This is a very common scenario: displaying images in a ListView which have to
In our current WinForms app, we are displaying millions of records in ListView, using
When displaying my DateTime values, I want them to be formatted like so: February
In my application has two Activities. One is main activity and other is activity

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.