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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T17:29:03+00:00 2026-06-01T17:29:03+00:00

please help me to create a list view dynamically and inflating it with some

  • 0

please help me to create a list view dynamically and inflating it with some run time data…..

Thanks in advance.

  • 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-01T17:29:04+00:00Added an answer on June 1, 2026 at 5:29 pm

    Extends ListActivity class and create object of ArrayList and use ArrayAdapter to add values.

    public class ListViewDemo extends ListActivity {
    
    
    //LIST OF ARRAY STRINGS WHICH WILL SERVE AS LIST ITEMS
    ArrayList<String> listItems=new ArrayList<String>();
    
    //DEFINING STRING ADAPTER WHICH WILL HANDLE DATA OF LISTVIEW
    ArrayAdapter<String> adapter;
    
    //RECORDING HOW MUCH TIMES BUTTON WAS CLICKED
    int clickCounter=0;
    
    @Override
    public void onCreate(Bundle icicle) {
    
    super.onCreate(icicle);
    setContentView(R.layout.main);
    adapter=new ArrayAdapter<String>(this,
        android.R.layout.simple_list_item_1,
        listItems);
    setListAdapter(adapter);
    }
    
    //METHOD WHICH WILL HANDLE DYNAMIC INSERTION
    public void addItems(View v) {
     listItems.add("Clicked : "+clickCounter++);
     adapter.notifyDataSetChanged();
    }
    }
    

    Also can be defined using layout xml,

    Create a xml layout in your projects res/layout/main.xml folder

    <?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" >
    <Button
    android:id="@+id/addBtn"
    android:text="Add New Item"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:onClick="addItems"/>
    <ListView
    android:id="@android:id/list"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:drawSelectorOnTop="false"
    />
    </LinearLayout>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi thanks for reading this! Please help me. I am trying to create a
Please help me create my own custom layout, container, component, layout manager... Example: Containers
Please help me with using the DrScheme built-in function filter. create a function hello
Please help me finding where I have made mistake? delimiter // CREATE FUNCTION `count_photos_in_gallery`(`tmp_gallery_id`
I wan't to create a map view like in ACL2011 app. here I list
Can you please help me understand the adapter with custom data : I was
I have a problem with returning data to view. I want to create a
Please help me to find out error in my SQL query. I have created
Please help me solve my big problem. in my on-line shopping project i created
Please help! I'm really at my wits' end. My program is a little personal

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.