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

The Archive Base Latest Questions

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

I am designing a simple app from tutorials that I have seen, and I

  • 0

I am designing a simple app from tutorials that I have seen, and I am attempting to simply display two text views in each row of a listview, a name and a price. This worked and I could select the row and it would activate an intent. However I then changed my xml code so that the listview would be placed in a linearLayout in order for me to have a header at the top of the screen. Now when I click on any of the rows they are highlighted but nothing else happens. I have already tried to making the textviews set to clickable = false in the xml but still no luck. I am hoping I am just missing something simple in the onCreate method. `public class ViewMenuListing extends ListActivity {

public static final String ROW_ID = "row_id"; // Intent extra key
private ListView contactListView; // the ListActivity's ListView
private CursorAdapter contactAdapter; // adapter for ListView
private String tableName;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    contactListView = getListView(); // get the built-in ListView
    contactListView.setOnItemClickListener(viewContactListener);

    setContentView(R.layout.viewmenu);

    //Get table name of menu clicked. 
    Bundle extras = getIntent().getExtras();
    tableName = extras.getString("table");

    // map each contact's name to a TextView in the ListView layout
    String[] from = new String[] { "name", "price" };
    int[] to = new int[] { R.id.itemTextView, R.id.priceTextView };
    //int[] to = new int[] { R.id.itemTextView};

    contactAdapter = new SimpleCursorAdapter(
            ViewMenuListing.this, R.layout.menu_list_item, null, from, to);
    setListAdapter(contactAdapter); // set contactView's adapter
 }`

The only thing I changed in this code was that I used the setContentView(R.layout.viewmenu) now when I didnt before and the list would just be the content view.

Here is my viewMenu file:

`

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/hello" />
    <ListView
        android:id="@+id/android:list"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"/>
</LinearLayout>`

and my menu_list_item.xml

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="horizontal">

   <TextView 
       android:layout_width="wrap_content"
       android:layout_height="wrap_content" 
       android:id="@+id/itemTextView"
       android:padding="8dp"
       android:clickable = "false"
       android:textSize="20sp" android:textColor="@android:color/white"
       android:minHeight="?android:attr/listPreferredItemHeight"
       android:gravity="center_vertical">
    </TextView>

   <TextView 
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:id="@+id/priceTextView"
       android:clickable = "false"
       android:textColor="@android:color/white"/>
 </LinearLayout>

Thank you for your help!

  • 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-31T10:12:55+00:00Added an answer on May 31, 2026 at 10:12 am

    Looks like you are explicitly setting an onItemClickListener for your ListView. This really isn’t necessary since you are extending ListActivity and ListActivity has a method you can override called onListItemClick(). I would override the onListItemClick() method instead of explicitly setting an onItemClickListener. http://developer.android.com/reference/android/app/ListActivity.html#onListItemClick(android.widget.ListView, android.view.View, int, long)

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

Sidebar

Related Questions

I'm new to designing OO systems. I have a simple Flash Cards app where
I'm designing a simple web-app in CI. I have a registration controller, and a
I'm designing an iPad app that will have a custom grid in it. The
I am designing a simple internal framework for handling time series data. Given that
Atleast defining my problem is simple... I have a Input control (Text) and a
I'm designing a simple Cocoa app. This is basically my second Cocoa app (despite
i am designing a simple android app,which has a check box displayed in the
I've just finished designing a small android app and have now come to a
I am designing a simple expenses app which keeps track of expenses I do
I'm designing a simple text editor using WxPython, and I want to put the

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.