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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:28:54+00:00 2026-05-31T13:28:54+00:00

I have one Activity in which I try to show some simple messages, and

  • 0

I have one Activity in which I try to show some simple messages, and then a list of items. So as I understand, I need two views: one for the simple layout, and one for the list of items which will be handled by the adapter.

Here is my code:

ArrayAdapter<SolutionTopic> adapter;        

ArrayList<SolutionTopic> problems = new ArrayList <SolutionTopic>( );   

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

// Load your layout
setContentView(R.layout.solution);

SolutionTopic s = new SolutionTopic ();
s.setSolutionTopicName( "Hello" );

problems.add(s);        

adapter = new ArrayAdapter<SolutionTopic>(this, R.layout.solution_topic_list, 
        R.id.label,  problems);

TextView solution_title  = (TextView) findViewById(R.id.solution_title);        
TextView solution_description = (TextView) findViewById(R.id.solution_description);

setListAdapter (adapter);

}

and here is the solution.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" >

<TextView
    android:id="@+id/solution_title"    
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="Label1"
    />  

<TextView
    android:id="@+id/solution_description"    
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="Label2"
    />  

</LinearLayout>

and here is the solution_topic_list.xml

<?xml version="1.0" encoding="utf-8"?>

<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:padding="10dp"
    android:textSize="16sp" >
</TextView>  

What I am not sure is how to get these two to render together. Ideally what I want to do is display the TextView messages first, and then the list of items.

Any idea how I can do that?

Thanks!

  • 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-31T13:28:54+00:00Added an answer on May 31, 2026 at 1:28 pm

    You shouldn’t remove the ListView from solution.xml, in that ListView your SolutionTopics will be displayed.

    To get the big picture, your interface would have three Views:

    -TextView: @+id/solution_title

    -TextView: @+id/solution_description

    -ListView: @android:id/list

    The ListView contains an undefined number of entries of solution_topic_list.xml.

    PD: The third parameter of ArrayAdapter (R.id.label) should be the id of the TextView in solution_topic_list.xml:

    <?xml version="1.0" encoding="utf-8"?>
    <TextView xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/label"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:padding="10dp"
        android:textSize="16sp" >
    </TextView>  
    

    You also should implement toString method in your SolutionTopic class, to get the desired String.

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

Sidebar

Related Questions

I have one android activity which extends ListActivity. Every time list items is pressed
I have one SubjectTabActivity and i need to show listview on this activity. But
I have one list activity which populates when I click on one tab, the
i have main activity in which i have Four menus. and i have one
I have an ArrayList of objects in one activity and I need this arrayList
This is my situation. I have two activities: ONE and TWO. In TWO activity
I have one activity which download data from the web. In middle of the
I have a service which runs two asynctasks. One is for receiving multicast packets
I have one activity(MyActivity), in which I have a grid view. Also I have
I have develop one application in which 3 activity. in first activity there are

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.