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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:12:31+00:00 2026-05-25T17:12:31+00:00

The requirement for my screen is like having a title bar at the top

  • 0

The requirement for my screen is like having a title bar at the top middle and followed by the list view when am trying to do that am not able to do like i got state name in every list item.I want that only in the top and once. And the screen shot of it is
screen shot

 <?xml version="1.0" encoding="utf-8"?>
    <TableLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="fill_parent"
     android:layout_height="fill_parent"
        >
      <TableRow>
      <TextView 
         android:layout_height="wrap_content"
         android:layout_width="fill_parent"
         android:background="#000000"
         android:text="Select State"
                
      ></TextView>
      </TableRow>
      <TableRow> 
      <TextView  android:layout_width="wrap_content"
          android:layout_height="fill_parent"
          
           android:id="@+id/label"
          android:textSize="30px"></TextView>
    </TableRow>
    </TableLayout>

I have tried many ways this is my present layout

and my java code is

import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;

public class new21 extends ListActivity {
    /** Called when the activity is first created. */
    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);
        // Create an array of Strings, that will be put to our ListActivity
        String[] names = new String[] { "Andhra Pradesh", "Kerala","Tamilnadu","Karnataka" };
        // Use your own layout and point the adapter to the UI elements which
        // contains the label
        this.setListAdapter(new ArrayAdapter<String>(this, R.layout.new21,
                R.id.label, names));
    }

    @Override
    
    protected void onListItemClick(ListView l, View v, int position, long id) {
        super.onListItemClick(l, v, position, id);
        // Get the item that was clicked
        Object o = this.getListAdapter().getItem(position);
        String keyword = o.toString();
        if(keyword.equals("Andhra Pradesh"))
        {
            Intent ima45=new Intent(new21.this,new31.class);
            startActivity(ima45);
    
        }
        Toast.makeText(this, "You selected: " + keyword, Toast.LENGTH_LONG)
                .show();
        
    }

}

Can any one help me.

  • 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-25T17:12:32+00:00Added an answer on May 25, 2026 at 5:12 pm

    You can addHeader to the ListView like this,

    View header = getLayoutInflater().inflate(R.layout.header, null);
    ListView listView = getListView();
    listView.addHeaderView(header);
    setListAdapter(new ArrayAdapter<String>(this,
                    android.R.layout.simple_list_item_single_choice, names));
    

    Where R.layout.header is the layout that contains a TextView with text "Select State"

    UPDATED:

    public class ListViewProblemActivity extends ListActivity {
    
        ListView listView;
    
        public void onCreate(Bundle icicle) {
            super.onCreate(icicle);
            // Create an array of Strings, that will be put to our ListActivity
            String[] names = new String[] { "Andhra Pradesh", "Kerala","Tamilnadu","Karnataka" };
            // Use your own layout and point the adapter to the UI elements which
            // contains the label
    
            TextView tv = new TextView(getApplicationContext());
            tv.setText("Select State");
    
            listView = getListView();
            listView.addHeaderView(tv);
            this.setListAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_expandable_list_item_1,names));
        }
    
        @Override
    
        protected void onListItemClick(ListView l, View v, int position, long id) {
            super.onListItemClick(l, v, position, id);
            // Get the item that was clicked
    
            if(position != 0){
                System.out.println(position - 1);
                Object o = this.getListAdapter().getItem(position - 1);
                String keyword = o.toString();
                Toast.makeText(this, "You selected: " + keyword, Toast.LENGTH_LONG)
                        .show();
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a requirement that the navigation bar be hidden by default. It will
I would like to develop a UI that includes draggable windows, a task bar
I have a requirement where i have a video playing on my screen and
Requirement : Should update MySQL database with that of MS Sql Server updates which
Requirement is like: I want to take input values from user in frame but
I do have a screen in which i placed 3 panels like Main Panel
As according to my project requirement, I want to split the screen into two
I have an application requirement where user chooses color & font for title, labels,
I'm having a requirement where i can press a logout button from any activity
I have a UIScrollView with the requirement that, when zooming, the contentSize.height should remain

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.