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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T21:35:20+00:00 2026-05-31T21:35:20+00:00

I created custom adapter for listview which contain text and images, on click of

  • 0

I created custom adapter for listview which contain text and images, on click of particular list item I have to open another activity, but I am not able to fire listview click event, below is my code.

Thanks.

Adapter

public class ImageAndTextAdapter extends ArrayAdapter<String> {

private LayoutInflater mInflater;
private Context myCtx;
private String[] mStrings;
private TypedArray mIcons;

private int mViewResourceId;

public ImageAndTextAdapter(Context ctx, int viewResourceId,
        String[] strings, TypedArray icons) {
    super(ctx, viewResourceId, strings);
    myCtx = ctx;
    mInflater = (LayoutInflater)ctx.getSystemService(
            Context.LAYOUT_INFLATER_SERVICE);

    mStrings = strings;
    mIcons = icons;

    mViewResourceId = viewResourceId;
}

@Override
public int getCount() {
    return mStrings.length;
}

@Override
public String getItem(int position) {
    return mStrings[position];
}

@Override
public long getItemId(int position) {
    return 0;
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    convertView = mInflater.inflate(mViewResourceId, null);

    ImageView iv = (ImageView)convertView.findViewById(R.id.option_icon);
    iv.setImageDrawable(mIcons.getDrawable(position));


    TextView tv = (TextView)convertView.findViewById(R.id.option_text);
    tv.setText(mStrings[position]);

    return convertView;
}
}

Main acitivity

public class OurWishingWellActivity extends ListActivity implements OnClickListener{
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
   // setContentView(R.layout.list_view_image);

    Context ctx = getApplicationContext();
    Resources res = ctx.getResources();

    String[] options = res.getStringArray(R.array.reg_item_names);
    TypedArray icons = res.obtainTypedArray(R.array.reg_icons);

    setListAdapter(new ImageAndTextAdapter(ctx, R.layout.list_item,
            options, icons));

}

@Override
public void onClick(View v) {
    // TODO Auto-generated method stub

}


}
  • 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-31T21:35:21+00:00Added an answer on May 31, 2026 at 9:35 pm

    Respected Aafag#

    You have write onclick of listview like below.

      @Override
    protected void onListItemClick(ListView l, View v, int position, long id) {
        // TODO Auto-generated method stub
        super.onListItemClick(l, v, position, id);
        Toast.makeText(AdvancedListViewActivity.this, "working", Toast.LENGTH_SHORT).show();
        System.out.println("working!!!!!!!!!");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a custom adapter to display different images in the each list
I have one listview.which contain one image ,text and one button .i had creted
I've created a custom ListView adapter/item. The item contains a CheckedTextView and a TextView.
I have a ListView with a custom list adapter (that extends BaseAdapter). My list
I have created a custom listview and adapter by extending BaseAdapter. Every time I
I have an activity with listview and attached footer. I created my custom adapter
I have created a custom Cursor Adapter for my list.The list gets some data
I have created a custom Base Adapter class, to populate a list view with
I am attempting to create a custom Adapter for my ListView since each item
I have created custom cell in which there are n number of image views.

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.