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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:09:17+00:00 2026-05-23T07:09:17+00:00

I have this code and I’d really liek to be able to get the

  • 0

I have this code and I’d really liek to be able to get the text otu of the item in the listview. I’ve done an example where i can get it to toast in a different type of listview, but not this one that i made. any helpers?
thx in advance 🙂

    private void listChoices(){
    mySQLiteAdapterChoices = new SQLiteAdapterChoices(this);
    mySQLiteAdapterChoices.openToRead();
    Cursor cursor = mySQLiteAdapterChoices.queueAll();
    startManagingCursor(cursor);
    String choic=SQLiteAdapterChoices.KEY_CHOICE_SUB;

    String[] from = new String[]{choic};
    int[] to = new int[]{R.id.textUserChoice};

    SimpleCursorAdapter cursorAdapter =
        new SimpleCursorAdapter(this, R.layout.userrow, cursor, from, to);
    setListAdapter(cursorAdapter);
    mySQLiteAdapterChoices.close();



    ListView lv = getListView();
    lv.setTextFilterEnabled(true);
    lv.setOnItemClickListener(new OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent, View view,
                int position, long id) {



            switch(position) {
            case 0:
                final String text = ("txtUserChoice");
                Toast.makeText(getApplicationContext(),
                        text,
                        Toast.LENGTH_SHORT).show();
                startActivity(new Intent(getApplicationContext(),
                        First.class));
                break;

…

XML from createcontrol.xml

<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout
android:id="@+id/widget0"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
>
<ListView 
android:id="@android:id/list"   

android:layout_width="305px"
android:layout_height="270px"
android:layout_x="8px"
android:layout_y="10px"
>
</ListView>
<EditText
android:id="@+id/txtEdt"
android:layout_width="185px"
android:layout_height="wrap_content"
android:text=""
android:textSize="18sp"
android:autoText="true"
android:capitalize="words"
android:layout_x="8px"
android:layout_y="293px"
>
</EditText>
<Button
android:id="@+id/btnNewItem"
android:layout_width="107px"
android:layout_height="wrap_content"
android:text="Submit"
android:layout_x="199px"
android:layout_y="295px"
>
</Button>
</AbsoluteLayout>

xml from userrow.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="?android:attr/listPreferredItemHeight"
    android:padding="6dip">
    <ImageView
        android:id="@+id/icon"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:layout_marginRight="6dip"
        android:src="@drawable/icon" />
    <LinearLayout
        android:orientation="vertical"
        android:layout_width="0dip"
        android:layout_weight="1"
        android:layout_height="fill_parent">
        <TextView
            android:id="@+id/textUserChoice"
            android:layout_width="fill_parent"
            android:layout_height="0dip"
            android:layout_weight="1"
            android:gravity="center_vertical"
        />

    </LinearLayout>
</LinearLayout>

Fixed Code Below.. I moved some of the variables up a couple scopes and changed the code to this

            case 0:
                int index = cursor.getColumnIndex(choic); 
                final String text = cursor.getString(index);
                Toast.makeText(getApplicationContext(),
                        text,
                        Toast.LENGTH_SHORT).show();
                startActivity(new Intent(getApplicationContext(),
                        First.class));
                break;
            case 1:....
  • 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-23T07:09:17+00:00Added an answer on May 23, 2026 at 7:09 am

    I think the problem is that you forgot to fetch the data from cursor. You wrote
    final String text = ("txtUserChoice");
    and you should write like
    int index = cursor.getColumnIndex(choic);
    final String text = cursor.getString(index);
    and make cursor and choic variable as instance member.

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

Sidebar

Related Questions

I have this code: <div class = content-dir-item> <p>Text input</p> <img src=./images/email.png class =
I have this code, which works fine, but I would like to be able
I have this code: <label for=subject accesskey=S>Subject</label> <select name=subject type=text id=subject> <option value=a dog>Dog</option>
I have this code & I've tired using JQuery's appendTo() function to get this
I have this code in my routes.db file: resources :users do member do get
I have this code snippet where we get a collection from COM Dll public
I have this code that edits addresses in a game to get unlimited ammo
I have this code to get the local date/time. It works but it seems
I have this code in jQuery, that I want to reimplement with the prototype
I have this code: chars = #some list try: indx = chars.index(chars) except ValueError:

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.