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

  • Home
  • SEARCH
  • 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 446729
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T21:29:59+00:00 2026-05-12T21:29:59+00:00

I coded an own Adapter and added it to my ListActivity via an ListView.

  • 0

I coded an own Adapter and added it to my ListActivity via an ListView.
The reason why I wrote an own Adapter is, that i had to make some layout changes to the list-entrys. In every entry of the list i’ve got 3 TextViews.

<?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">
<TextView
    android:id="@+id/myNr"
    android:layout_width="40dip"
    android:layout_height="fill_parent"
    android:layout_marginRight="15dip"
    android:text="id" 
    android:textSize="25dip"
    android:background="#333333"
    android:gravity="center_horizontal"/>
<LinearLayout
    android:orientation="vertical"
    android:layout_width="0dip"
    android:layout_weight="1"
    android:layout_height="fill_parent">
    <TextView
        android:id="@+id/editor"
        android:layout_width="fill_parent"
        android:layout_height="0dip"
        android:layout_weight="1"
        android:gravity="center_vertical"
        android:text="Editor: " />
    <TextView
        android:id="@+id/date"
        android:layout_width="fill_parent"
        android:layout_height="0dip"
        android:layout_weight="1" 
        android:singleLine="true"
        android:ellipsize="marquee"
        android:text="Date: " />
</LinearLayout>

The next thing i did, was to implement a “onListItemClick-Methode”. Afterwards i implemented a onListItemLongClick – Listener with the following code:

in onCreate of the Activity i added:

 registerForContextMenu(getListView());

then i added the following methode:

Override
public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo menuInfo){
         AdapterView.AdapterContextMenuInfo info;
         info = (AdapterView.AdapterContextMenuInfo) menuInfo;
            long id = getListAdapter().getItemId(info.position);
        }

where “id” is the index of the item in the list.
I now want to get the Text of the texview with the id=”myNr of this ListItem.
Is there any way get this Text?

  • 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-12T21:29:59+00:00Added an answer on May 12, 2026 at 9:29 pm

    I found another way to set an ItemLongClickListener. Therefore I also found a way to get the Text I am displaying.

    ListView lv = getListView();
    lv.setOnItemLongClickListener(new OnItemLongClickListener(){
    @Override
    public boolean onItemLongClick(AdapterView<?> arg0, View arg1,int row, long arg3) {
       String[] tmp = (String[]) arg0.getItemAtPosition(row);
       //tmp[0] ist the Text of the first TextView displayed by the  clicked ListItem 
       return true;
       }});
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application that allows users to write their own code in a
I have several blocks of the following code that each use there own matrix.
I coded up 4 .java files. The thing is that I can only execute
I am currently trying to code my own JS drag and drop script (out
I'm starting to code up my own window manager, and was wondering how to
I am wrapping existing C++ code from a BSD project in our own custom
I've been successful with writing my own SQL access code with a combination of
I am running the C# compiler in code, sort of my own IDE. I
I coded something using Date statement in Access VBA. It was working fine until
I have never hand-coded object creation code for SQL Server and foreign key decleration

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.