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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:33:21+00:00 2026-05-26T08:33:21+00:00

I only have a ListView containing TextView. I would like to add an image

  • 0

I only have a ListView containing TextView. I would like to add an image and a button to each row in the list, such that when i click on the button, it will send the data gotten from SimpleCursorAdapter and bring me to another activity.

I have got two xml files. one that contains the ListView and the other xml file contains the TextView, ImageView and Button.

I have read many articles in stackoverflow and online, but i still cant get it working. I think there is something which is got to do with the getView(), onClickListener for the button but i do not know how to link it together with the SimpleCursorAapter class. As in my case, i did not extend SimpleCursorAdapter but used it directly. I am confused about how to allow it to access the xml file which contains the button and image. my current code is like this:

public class BoardsActivity extends ListActivity {
private static final int ACTIVITY_SUBSCRIBE = 0;
private AnnouncementDbAdapter dbAdapter;
private Cursor cursor;
private Button subscribeButton;
//private LayoutInflater mInflater;

@Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.subscribe_to);
    // mInflater = (LayoutInflater) getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
    dbAdapter = new AnnouncementDbAdapter(this);
    //      dbAdapter.open();
    //      fillData();


@Override
protected void onResume() {
super.onResume();
dbAdapter.open();
fillData();

@Override
protected void onPause() {
super.onPause();
dbAdapter.close();

private void fillData() {
cursor = dbAdapter.fetchAllBoards();
startManagingCursor(cursor);

String[] from = new String[] {AnnouncementDbHelper.BNAME };
int[] to = new int[] {R.id.subscribeactivity_bname};

SimpleCursorAdapter board = new SimpleCursorAdapter(this,R.layout.subscribe_to_row, cursor, from, to);
setListAdapter(board);

@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
Cursor details = dbAdapter.fetchBoard(id);
startManagingCursor(details);

Intent i = new Intent(this, BoardDetailsActivity.class);
i.putExtra(AnnouncementDbHelper.BID, id);
startActivityForResult(i, ACTIVITY_SUBSCRIBE);

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
super.onActivityResult(requestCode, resultCode, intent);
dbAdapter.open();
fillData();}

How can i get the image from Drawables and when the user clicks on the button, it goes to another activity?

  • 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-26T08:33:22+00:00Added an answer on May 26, 2026 at 8:33 am

    For this you need to create Custom List view that will displays Textview,ImageView and button.

    Check this for Custom list view

    Also check this List View and Adapters available

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

Sidebar

Related Questions

I have a ListView. When I select a row I want that only one
I have an ownerdrawn ListView that smears when I scroll. It only affects the
I have a MySQL table that will only have one row. What should my
In one of my Activities I have a ListView that displays a list of
I have a ListView whose rows are formatted by me. Each row has a
I have a view containing a ListView and an Edit Button. The ListView's ItemSource
I have a listview that you select a row/item on. This is linked to
I have a ListView containing only buttons. What I want to do is pretty
I have a ListView that is being populated with a custom adapter. I'd like
I have a listview which is customized to display an image and 2 textview.

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.