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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T17:25:18+00:00 2026-06-17T17:25:18+00:00

Im trying to make ListView using data from Array, but I need to get

  • 0

Im trying to make ListView using data from Array, but I need to get Id of clicked row (not shown in that row, but userd in creation of that product)

Im using this class for object:

package com.example.raidplanner;
public class RaidWpis {
private int id;
private int id_gildia;
private String nazwa;
private int schemat;
private int data_zapis;
private int data_start;
private int opis;
private int id_officer;
private int nick_officer;
private int typ;

public RaidWpis(int id,String nazwa) {
    setNazwa(nazwa);
    setId(id);
}

public int getId()                  { return id; }

public void setId(int id)           { this.id = id; }

public String getNazwa()            { return nazwa; }

public void setNazwa(String nazwa)  { this.nazwa = nazwa; }

public String toString() {
        return this.nazwa;
    }
    public String toString2() {
        return this.id+" - "+nazwa;
    }

}

And this code in Activity:

RaidWpis[] items = {
            new RaidWpis(1, "aaaa"),
            new RaidWpis(3, "bbbb"),
            new RaidWpis(6, "cccc"),
            new RaidWpis(11, "dddd"),
            new RaidWpis(17, "eeee"),
        };        
    mainListView = (ListView) findViewById( R.id.mainListView );  

    ArrayAdapter<RaidWpis> raidList = new ArrayAdapter<RaidWpis>(this, R.layout.simplerow, items);  

    // Create ArrayAdapter using the raid list.  
    mainListView.setAdapter(raidList);

    mainListView.setOnItemClickListener(new OnItemClickListener() {
          @Override
            public void onItemClick(AdapterView<?> parent, View view, int position,
                    long id) 
          {
                String item = ((TextView)view).getText().toString();
                Toast.makeText(getBaseContext(), item, Toast.LENGTH_LONG).show();   
          }
        });
  • 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-06-17T17:25:20+00:00Added an answer on June 17, 2026 at 5:25 pm

    I need to get Id of clicked row (not shown in that row, but userd in creation of that product)

    Try this in your onItemClick() method:

    RaidWpis obj = parent.getAdapter().getItem(position); // or just raidList.get(position) if raidList is a field variable
    Toast.makeText(getBaseContext(), obj.getID() + "", 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 am trying to make an app that parses data from Twitter using JSON
I'm trying to make a listview from an arraylist using the tutorial i found
I was wondering : I'm trying to make an app that as a Listview,
I've got problem. I'm using windows.forms ListView to show some data and I need
Im trying to make a request from last.fm where I will get similar artists
I'm trying to make 'dynamic' listview that contains 0-2 headers and 0-1 footer(based on
OK, so I am trying to make a program using Visual Basic that will
I'm trying to set the View for my ListView dynamically: But I get an
Im trying to make a Manga Rss-Reader app using the XmlPullParser that was used
I have a ListView which is populated from a string-array resource. I'm trying to

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.