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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T20:25:16+00:00 2026-05-30T20:25:16+00:00

I create a custom listview and it extend ListActivity and works fine. But I

  • 0

I create a custom listview and it extend ListActivity and works fine. But I want to put a ListView in my main activity that extends Activity. How can I do this?

For example, I want to put a custom ListView in my one part of my screen not the screen filled by only ONE ListView that extends ListActivity.

<?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/lvresult"
    android:paddingTop="2dip"
    android:paddingBottom="3dip"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" /> 
  </LinearLayout>

and this is MyListActivity:

package Dic.proj.pkg;
import java.util.ArrayList;
import android.app.ListActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
public class MyListActivity extends ListActivity {
EditText et;
TextView tv;
TextView tvresult;
String resulttext;
ArrayList<String> mArrayList = new ArrayList<String>();
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    String[] values = new String[] { "Android", "iPhone", "WindowsMobile",
            "Blackberry", "WebOS", "Ubuntu", "Windows7", "Max OS X",
            "Linux", "OS/2" };
    // Use your own layout
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
            R.layout.customlist, R.id.lvresult, values);
    setListAdapter(adapter);
}

@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
    String item = (String) getListAdapter().getItem(position);
    Toast.makeText(this, item + " selected", Toast.LENGTH_LONG).show();
  }
 }

This works fine but I can see only one List view on screen. I want to put this custom Listview in my main activity. How can I do this?

  • 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-30T20:25:17+00:00Added an answer on May 30, 2026 at 8:25 pm

    you do like below:-

    public class StoreListActivity extends Activity {
        private List<Store> mStores;
        private StoreAdapter mStoreAdapter;
        private ListView mListView;
    
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.store_list);
            mListView = (ListView) findViewById(R.id.store_listview);
    
                mStores = getTheStoresFromSomewhere();
            mStoreAdapter = new StoreAdapter(this, mStores);
            mListView.setAdapter(mStoreAdapter);
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to create custom AlertDialog, but without AlertDialog.Builder. I set ListView as content
I think I know how to create custom encrypted RSA keys, but how can
I am trying to create custom background selector for my ExpandableListView. It works fine
I create a dialog and populate it with a listview that uses a custom
I am attempting to create a custom Adapter for my ListView since each item
I need create custom dialog and put JPanel into it. Is it possible?
Can i create custom touch events for iPhone?? will the device support for creating
I am trying to create a custom listview in android by extending ListView. The
I am trying to create a list view which as TextView that can display
I have a ListView that I want to use with an ArrayAdapter to add

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.