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

  • Home
  • SEARCH
  • 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 7556037
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T11:46:15+00:00 2026-05-30T11:46:15+00:00

The Code below displays a dialog after clicking on a ListView’s Item.I would instead

  • 0

The Code below displays a dialog after clicking on a ListView’s Item.I would instead like to create my own Dynamic Layout displaying the text views about the particular List Entry in the ListView. Can Someone please help?

package com.android.XYZ;

import java.util.List;
import java.util.Vector;

import android.app.Activity;
import android.app.ListActivity;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;

import android.widget.ScrollView;
import android.widget.LinearLayout;


public class News_01 extends ListActivity {
    private LayoutInflater mInflater;
    private Vector<RowData> data;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        mInflater = (LayoutInflater) getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
        data = new Vector<RowData>();
        RowData rd; 
        rd = new RowData("Detailed Report 1", "Story 1");
        data.add(rd);
        rd = new RowData("Detailed Report 2", "Story 2");
        data.add(rd);
        rd = new RowData("Detailed Report 3", "Story 3");
        data.add(rd);
        rd = new RowData("Detailed Report 4", "Story 4");
        data.add(rd);
        rd = new RowData("Detailed Report 5", "Story 5");
        data.add(rd);
        rd = new RowData("Detailed Report 6", "Story 6");
        data.add(rd);
        rd = new RowData("Detailed Report 7", "Story 7");
        data.add(rd);
        rd = new RowData("Detailed Report 8", "Story 8");
        data.add(rd);
        rd = new RowData("Detailed Report 9", "Story 9");
        data.add(rd);
        rd = new RowData("Detailed Report 10", "Story 10");
        data.add(rd);

        CustomAdapter adapter = new CustomAdapter(this, R.layout.news_01,R.id.text_1, data);
        setListAdapter(adapter);        
        getListView().setTextFilterEnabled(true);       
    }


    public void onListItemClick(ListView parent, View v, int position, long id) {
        CustomAdapter adapter = (CustomAdapter) parent.getAdapter();
            RowData row = adapter.getItem(position);

New Code –> (This is what i want to display after someone clicks on any item on the ListView)
ScrollView sv = new ScrollView(this);

            sv.setBackgroundColor(Integer.parseInt("d3d3d3", 16));

            LinearLayout ll = new LinearLayout(this);

            ll.setOrientation(LinearLayout.VERTICAL);

            sv.addView(ll);

            TextView tv = new TextView(this);

            tv.setText(row.mTitle);

            ll.addView(sv);

I want to add the hard coded dynamic layout whenever we click
a list view’s Item?

Original Code—>

        Builder builder = new AlertDialog.Builder(this);

        builder.setTitle(row.mDescription); 

        builder.setMessage(row.mTitle + " -> " + position );

        builder.setPositiveButton("ok", null);

        builder.show();

        }

    /**
     * Data type used for custom adapter. Single item of the adapter.      
     */
    private class RowData {
        protected String mTitle;
            protected String mDescription;

            RowData(String title, String description){
                mTitle = title;
                mDescription = description;                                  
        }

            @Override
            public String toString() {
                    return mTitle + " " +  mDescription;
            }
    }

    private class CustomAdapter extends ArrayAdapter<RowData> {

            public CustomAdapter(Context context, int resource,
                            int textViewResourceId, List<RowData> objects) {
                    super(context, resource, textViewResourceId, objects);

            }

            @Override
            public View getView(int position, View convertView, ViewGroup parent) {
                    ViewHolder holder = null;

                    //widgets displayed by each item in your list
                    TextView item = null;
                    TextView description = null;

                    //data from your adapter
                    RowData rowData= getItem(position);


                    //we want to reuse already constructed row views...
                    if(null == convertView){
                            convertView = mInflater.inflate(R.layout.news_01, null);
                            holder = new ViewHolder(convertView);
                            convertView.setTag(holder);
                    }
                    // 
                    holder = (ViewHolder) convertView.getTag();
                    item = holder.getItem();
                    item.setText(rowData.mTitle);

                    description = holder.getDescription();          
                    description.setText(rowData.mDescription);

                    return convertView;
            }
    }

    /**
     * Wrapper for row data.
     *
     */
    private class ViewHolder {      
        private View mRow;
        private TextView description = null;
        private TextView item = null;

            public ViewHolder(View row) {
            mRow = row;
            }

            public TextView getDescription() {
                    if(null == description){
                            description = (TextView) mRow.findViewById(R.id.text_1);
                    }
                    return description;
            }

            public TextView getItem() {
                    if(null == item){
                            item = (TextView) mRow.findViewById(R.id.text_1);
                    }
                    return item;
            }       
    }}


  [1]: https://i.stack.imgur.com/q6YIO.png
  [2]: https://i.stack.imgur.com/vC65C.png
  • 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-30T11:46:17+00:00Added an answer on May 30, 2026 at 11:46 am

    I think you want a custom dialog. Try this

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

Sidebar

Related Questions

The code snippet below displays a Dialog with a simple login-form. The problem is
The line of code below displays a dialog box with two buttons: Yes and
In the code below, I would like to display a status message while fetching
In the code below, $row['site'] is an URL. In Chrome and IE8, it displays
The below HTML/CSS/Javascript (jQuery) code displays the #makes select box. Selecting an option displays
Greetings, The VBA code below will create an Excel QueryTable object and display it
I have a simple MFC program which displays the progressbar..I used the below code
Working with MVC3, Razor, Jquery, Javascript. The below code loops through and displays a
I am trying to create a custom dialog box that displays an image in
In the below code the JProgressBar displays correctly when the doSomething() is called from

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.