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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T06:12:23+00:00 2026-06-01T06:12:23+00:00

I have fetched images and text as listview from database.now on clicking the particular

  • 0

I have fetched images and text as listview from database.now on clicking the particular text or image i should print same text.
Eg: if i click the listview of food menu then it should print food menu.if i click list view of catalogue it should print the catalogue .

enter code here
JSONArray json = jArray.getJSONArray("mainmenu");
        list=(ListView)findViewById(R.id.mainmenulist);
         adapter=new MainMenulist(this, json);
         list.setAdapter(adapter);

Main menu listview
  public class MainMenulist extends BaseAdapter {
protected static Context Context = null;
int i;
String qrimage;
Bitmap bmp, resizedbitmap;
Bitmap[] bmps;
Activity activity = null;
private LayoutInflater inflater;

private ImageView[] mImages;
String[] itemimage;
TextView[] tv;
String itemname;
public String[] itemnames;
HashMap<String, String> map = new HashMap<String, String>();

public MainMenulist(Context context, JSONArray imageArrayJson) {
    Context = context;
    // inflater =
    // (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    // imageLoader=new ImageLoader(activity);
    inflater = LayoutInflater.from(context);
    this.mImages = new ImageView[imageArrayJson.length()];
    this.bmps = new Bitmap[imageArrayJson.length()];
    this.itemnames = new String[imageArrayJson.length()];

    try {

        for (i = 0; i < imageArrayJson.length(); i++) {
            JSONObject image = imageArrayJson.getJSONObject(i);
            qrimage = image.getString("menuimage");
            itemname = image.getString("menuname");
            itemnames[i] = itemname;

            byte[] qrimageBytes = Base64.decode(qrimage.getBytes());

            bmp = BitmapFactory.decodeByteArray(qrimageBytes, 0,
                    qrimageBytes.length);
            int width = 100;
            int height = 100;
            resizedbitmap = Bitmap.createScaledBitmap(bmp, width, height,
                    true);
            bmps[i] = bmp;

            mImages[i] = new ImageView(context);
            mImages[i].setImageBitmap(resizedbitmap);

            mImages[i].setScaleType(ImageView.ScaleType.FIT_START);

            // tv[i].setText(itemname);
        }
        System.out.println(itemnames[i]);
        System.out.println(map);

    } catch (Exception e) {
        // TODO: handle exception
    }
}

public int getCount() {
    return mImages.length;
}

public Object getItem(int position) {
    return position;
}

public long getItemId(int position) {
    return position;
}

public View getView(final int position, View convertView, ViewGroup parent) {

    View vi = convertView;

    vi = inflater.inflate(R.layout.mainmenulistview, null);

    TextView text = (TextView) vi.findViewById(R.id.menutext);
    ImageView image = (ImageView) vi.findViewById(R.id.menuimage);
    image.setImageBitmap(bmps[position]);

    text.setText(itemnames[position]);
    text.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {
            // TODO Auto-generated method stub
            if (itemnames[position].equals("Food Menu")) {
                Intent intent = new Intent(Context, FoodMenu.class);
                System.out.println("prakash");
                Context.startActivity(intent);
            }
        }
    });

    return vi;

}

  }

i can fetch all items in menulistview.java please tell me how to get particular list view click means particular item prints

  • 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-01T06:12:24+00:00Added an answer on June 1, 2026 at 6:12 am

    Check below code

    text.setOnClickListener(new OnClickListener() {
    
        public void onClick(View v) {
            // TODO Auto-generated method stub
            if (itemnames[position].equals("Food Menu")) {
                Intent intent = new Intent(Context, FoodMenu.class);
                System.out.println("prakash");
                System.out.println(v.getText().toString());
                Context.startActivity(intent);
            }
        }
    });
    

    Think you want to print name as you suggested at the place of your
    System.out.println statement

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

Sidebar

Related Questions

Ok, so I have a script to fetched images from Google's Picasa image service
I have fetched some data from a SQL database into a datagridview, but after
I have a byte array which contains an image fetched from the net. I
I have few images on a web page which are fetched from HTTP server
I have fetched a result from core data in my app and need to
I have a hidden property which is fetched from ebean. how do i pass
I have string that look like Array that fetched from other webservice like this
I have two tables with list of urls fetched from different sources. I want
I have a problem related to an array data which fetched from an external
I have a big list of over 20000 items to be fetched from DB

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.