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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T17:10:35+00:00 2026-06-13T17:10:35+00:00

Hi all In my application I am showing multicolumn listview (list had 3 columns),

  • 0

Hi all In my application I am showing multicolumn listview (list had 3 columns), but in my application it is showing all columns same vaue. My listview layout is like:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:paddingBottom="5dip"
android:paddingLeft="5dip"
android:paddingTop="5dip" >

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:weightSum="3" >

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="2dip"
        android:layout_marginRight="2dip"
        android:layout_weight="1"
        android:background="@drawable/listbackground"
        android:gravity="center"
        android:orientation="vertical" >

        <TextView
            android:id="@+id/Name"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textColor="#C20000"
            android:textSize="14sp"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/ltp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="2dip"
            android:layout_marginRight="2dip"
            android:layout_weight="1"
            android:gravity="center"
            android:orientation="horizontal" >

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentLeft="true"
                android:layout_centerVertical="true"
                android:src="@drawable/down" />

            <TextView
                android:id="@+id/perChange"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />
        </LinearLayout>
    </LinearLayout>

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="2dip"
        android:layout_marginRight="2dip"
        android:layout_weight="1"
        android:background="@drawable/listbackground"
        android:gravity="center"
        android:orientation="vertical" >

        <TextView
            android:id="@+id/Name1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textColor="#C20000"
            android:textSize="14sp"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/ltp1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="2dip"
            android:layout_marginRight="2dip"
            android:layout_weight="1"
            android:gravity="center"
            android:orientation="horizontal" >

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentLeft="true"
                android:layout_centerVertical="true"
                android:src="@drawable/down" />

            <TextView
                android:id="@+id/perChange1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />
        </LinearLayout>
    </LinearLayout>

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="2dip"
        android:layout_marginRight="2dip"
        android:layout_weight="1"
        android:background="@drawable/listbackground"
        android:gravity="center"
        android:orientation="vertical" >

        <TextView
            android:id="@+id/Name2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textColor="#C20000"
            android:textSize="14sp"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/ltp2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="2dip"
            android:layout_marginRight="2dip"
            android:layout_weight="1"
            android:gravity="center"
            android:orientation="horizontal" >

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentLeft="true"
                android:layout_centerVertical="true"
                android:src="@drawable/down" />

            <TextView
                android:id="@+id/perChange2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />
        </LinearLayout>
    </LinearLayout>
</LinearLayout>

     final ListView lv = (ListView) findViewById(R.id.srListView);
    lv.setAdapter(new MyCustomBaseAdapter(this, searchResults));


public class MyCustomBaseAdapter extends BaseAdapter {
    private ArrayList<SearchResults> searchArrayList;

    private LayoutInflater mInflater;

    public MyCustomBaseAdapter(Context context,
            ArrayList<SearchResults> results) {
        searchArrayList = results;
        mInflater = LayoutInflater.from(context);
    }

    public int getCount() {
        return searchArrayList.size();
    }

    public Object getItem(int position) {
        return searchArrayList.get(position);
    }

    public long getItemId(int position) {
        return position;
    }

    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if (convertView == null) {
            convertView = mInflater.inflate(R.layout.custom_row_view, null);
            holder = new ViewHolder();
            holder.txtName = (TextView) convertView
                    .findViewById(R.id.Name);
            holder.txtCityState = (TextView) convertView
                    .findViewById(R.id.ltp);
            holder.txtPhone = (TextView) convertView
                    .findViewById(R.id.perChange);

            holder.txtName1 = (TextView) convertView
                    .findViewById(R.id.Name1);
            holder.txtCityState1 = (TextView) convertView
                    .findViewById(R.id.ltp1);
            holder.txtPhone1 = (TextView) convertView
                    .findViewById(R.id.perChange1);

            holder.txtName2 = (TextView) convertView
                    .findViewById(R.id.Name2);
            holder.txtCityState2 = (TextView) convertView
                    .findViewById(R.id.ltp2);
            holder.txtPhone2 = (TextView) convertView
                    .findViewById(R.id.perChange2);

            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }

        System.out.println("position::" + position);

        holder.txtName
                .setText(searchArrayList.get(position).getStockCode());
        holder.txtCityState.setText(searchArrayList.get(position).getLtp());
        holder.txtPhone.setText(searchArrayList.get(position)
                .getPerChange());

        holder.txtName1.setText(searchArrayList.get(position)
                .getStockCode());
        holder.txtCityState1
                .setText(searchArrayList.get(position).getLtp());
        holder.txtPhone1.setText(searchArrayList.get(position)
                .getPerChange());

        holder.txtName2.setText(searchArrayList.get(position)
                .getStockCode());
        holder.txtCityState2
                .setText(searchArrayList.get(position).getLtp());
        holder.txtPhone2.setText(searchArrayList.get(position)
                .getPerChange());

        return convertView;
    }

    class ViewHolder {
        TextView txtName;
        TextView txtCityState;
        TextView txtPhone;

        TextView txtName1;
        TextView txtCityState1;
        TextView txtPhone1;

        TextView txtName2;
        TextView txtCityState2;
        TextView txtPhone2;
    }
}

It shows me output as

enter image description here

Now here it shows all column same data, but what I want is to show all column different data, How to do this? Any help/suggestion will be appreciated, Thanks in advance.

Thank you Sam but Now there is issue if Name is large then my output look as: Suppose Vishal becomes Vishalllllllllllllllllllll

enter image description here

  • 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-13T17:10:37+00:00Added an answer on June 13, 2026 at 5:10 pm

    Can I use three rows in that one box which is in gridview? If yes can you show me any sample/tutorial .

    Here is how to modify your existing code example to use a GridView.

    First simplify your layout to one box, save it as grid_item.xml:

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="2dip"
        android:layout_marginRight="2dip"
        android:layout_weight="1"
        android:background="@drawable/listbackground"
        android:gravity="center"
        android:orientation="vertical" >
    
        <TextView
            android:id="@+id/Name"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textColor="#C20000"
            android:textSize="14sp"
            android:textStyle="bold" />
    
        <TextView
            android:id="@+id/ltp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
    
        <TextView
            android:id="@+id/perChange"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:drawableLeft="@drawable/down" />
    
    </LinearLayout>
    

    (Notice that I combined the last TextView and ImageView, you may need to adjust this.)

    Second simplify your getView method:

    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if (convertView == null) {
            // Change the layout that is loaded
            convertView = mInflater.inflate(R.layout.grid_item, null);
            holder = new ViewHolder();
            holder.txtName = (TextView) convertView
                    .findViewById(R.id.Name);
            holder.txtCityState = (TextView) convertView
                    .findViewById(R.id.ltp);
            holder.txtPhone = (TextView) convertView
                    .findViewById(R.id.perChange);
    
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
    
        System.out.println("position::" + position);
    
        SearchResult result = searchArrayList.get(position);
        holder.txtName.setText(result.getStockCode());
        holder.txtCityState.setText(result.getLtp());
        holder.txtPhone.setText(result.getPerChange());
        return convertView;
    }
    
    class ViewHolder {
        TextView txtName;
        TextView txtCityState;
        TextView txtPhone;
    }
    

    Last Change these references (and any others that you may have):

    final GridView gv = (GridView) findViewById(R.id.srGridView);
    gv.setAdapter(new MyCustomBaseAdapter(this, searchResults));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi All, In my iPhone Application when I run it on device showing these
i created one grid view application, it's working fine now showing all images in
How can I list all instantiated objects in all application, using FASTMM4 or default
i want to get list of all application or Threads attached with a process.For
i'm developing an application where all the pojos are exposed as interface but we
I have an application with three MDI windows, all of them showing OpenGL content.
I want to get the android gallery view into my application with showing all
All, 1.) I have a Dialog showing on my application. Right now it is
When i run my application in development my datatables table is showing but when
Here is a simplified version of my application showing what I'm doing. /* in

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.