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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T12:20:23+00:00 2026-06-06T12:20:23+00:00

I need to display image and text in my listview when i click a

  • 0

I need to display image and text in my listview when i click a button search but it giving me an error in my setListAdapter(new MobileArrayAdapter(this, PNames,PImages));.. I have two classes.
When I display onformLoad it working but, now I need to display it using a buttton, here my two classess :

    B_KZN.setOnClickListener(new View .OnClickListener() {

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

   JSONObject json = JSONfunctions.getJSONfromURL("http://10.0.2.2/php/p.php");

   try{

            JSONArray  earthquakes = json.getJSONArray("SKZN");

           for(int i=0;i<earthquakes.length();i++){                     

            JSONObject e = earthquakes.getJSONObject(i);    
            String BookName = e.getString("P_City");
        PNames.add(BookName);
    String BookImg = e.getString("Pname");
        PImages.add(BookImg);
    }       
        }catch(JSONException e){
         Log.e("log_tag", "Error parsing data "+e.toString());
    }                   
        setListAdapter(new MobileArrayAdapter(this, PNames,PImages));

And my second Class, :

public class MobileArrayAdapter extends ArrayAdapter<String> {
    private final Context context;
    private final String[] myBookNamelist = null;
    private ArrayList<String> MyP = new ArrayList<String>();
    private ArrayList<String> myPurl = new ArrayList<String>();

    public MobileArrayAdapter(Context context,ArrayList<String> Bname,ArrayList<String> BUrl) {
        super(context, R.layout.list_mobile, Bname);
        this.context = context;
        this.MyP = Bname;
        this.myPurl = BUrl;
    }

here my error : The constructor MobileArrayAdapter(new View.OnClickListener(){}, ArrayList<String>, ArrayList<String>) is undefined…it showing me red line.

  • 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-06T12:20:24+00:00Added an answer on June 6, 2026 at 12:20 pm

    Your declaring this as your Context. But you are in an Annoymous class of type View.OnClickListener

    try this instead:

     setListAdapter(new MobileArrayAdapter(YourActivityName.this, PNames,PImages));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to display image and one button on fancybox popup but I can't
I need to display an image, which I've done without problems before, but today
I need to validate various ASP.NET controls, but instead of displaying the standard text/asterisk/image
In my android app I need to display a text on an image. The
I have a image centered on the screen. I need to display some text
this is my code to display listview in customized format .but my requirement is
I have a image 'm1' and a text 'Sample text'. i need to display
I need to resize an image to display on different pages in different sizes,
I display set of images(small). I need to show the larger image(300*300) at some
I need to display an image in a Django form. My Django form is

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.