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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T05:15:10+00:00 2026-05-16T05:15:10+00:00

i’m creating a lazy load of image in ListView. i was followed the tutorial

  • 0

i’m creating a lazy load of image in ListView.
i was followed the tutorial from this source which i found in Stack Overflow
It was run successful.

But, when i join the code together with my project then i face a problem. the program was no perform the OnItemClickListener 🙁

my project have a TabHost and it had 5 tab contents. 2 contents is using the ListActivity and run perfectly.

here is my coding, Main.java:

public class ProductListing extends Activity {
ListView list;
MyListAdapter adapter;
Controller c;
ImageLoader imageLoader;
TextView select;

//========== JSON ===========
ArrayList<String> strName = new ArrayList<String>();
ArrayList<String> strImage = new ArrayList<String>();
ArrayList<String> strDesc = new ArrayList<String>();
ArrayList<String> strSize = new ArrayList<String>();
JSONObject jsonObject;  
String[] listItem;
Context context;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            LoadJSON();
            setContentView(R.layout.productlisting_tab);
            list=(ListView)findViewById(R.id.ListView01);
            c = new Controller(this);
            adapter=new MyListAdapter(this,this, strName, strImage,strDesc,strSize);
            list.setAdapter(adapter); 
            list.setOnItemClickListener(new OnItemClickListener(){
        @Override
    public void onItemClick(AdapterView<?> parent, View view,
            int position, long id) {
        // TODO Auto-generated method stub
        System.out.println("Item Clicked");
    }
        });


    }

    public void LoadJSON(){
        try {
            InputStream is = this.getResources().openRawResource(R.raw.premium);
            byte[] buffer;
            buffer = new byte[is.available()];
            while(is.read(buffer) != -1);
            String jsonText = new String(buffer);

            jsonObject = new JSONObject(jsonText);
            JSONObject premium_tab = jsonObject.getJSONObject("premium_tab");               

            int totalItem = premium_tab.getInt(".total");
            for (int i = 1; i <= totalItem; i++) {
                JSONObject premium = premium_tab.getJSONObject("premium_"+i);
                String tempName =premium.getString(".name").toString();
                String tempImg = premium.getString(".image").toString();
                String tempDesc = premium.getString(".desc").toString();
                String tempSize = premium.getString(".size").toString();
                strName.add(tempName);
                strImage.add(tempImg);
                strDesc.add(tempDesc);
                strSize.add(tempSize);
            }
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
  }

MyListAdapter.java:

 public MyListAdapter(Context b,Activity a, ArrayList<String> strName, ArrayList<String> strImage,
            ArrayList<String> strDesc, ArrayList<String> strSize) {
    activity = a;
    name = strName;
    image = strImage;
    desc = strDesc;
    size = strSize;        
    inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    imageLoader=new ImageLoader(activity.getApplicationContext());
}

public int getCount() {
    return image.size();
}

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

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

public static class ViewHolder{
    public TextView ProductName,ProductSize, ProductDesc;
    public ImageView ProductIcon;
}

public View getView(int position, View convertView, ViewGroup parent) {
    View vi=convertView;
    ViewHolder holder;
    if(convertView==null){
        vi = inflater.inflate(R.layout.productlisting, null);
        holder=new ViewHolder();
        holder.ProductName=(TextView)vi.findViewById(R.id.text);
        holder.ProductIcon=(ImageView)vi.findViewById(R.id.image);
        holder.ProductDesc=(TextView)vi.findViewById(R.id.textdesc);
        holder.ProductSize=(TextView)vi.findViewById(R.id.textsize);
        vi.setTag(holder);
    }
    else
        holder=(ViewHolder)vi.getTag();

    holder.ProductName.setText(name.get(position));
    holder.ProductDesc.setText(desc.get(position));
    holder.ProductIcon.setTag(image.get(position));
    holder.ProductSize.setText(size.get(position));
    imageLoader.DisplayImage(image.get(position), activity, holder.ProductIcon);
    return vi;
  }    
}

Another class which name ImageLoader.java please refer the source link above.
May i know where is my mistake? i understand my code will very ugly, i’m a new in android please help me to solve the problem. it was stuck me for few days.
your reply is very appreciated !!!

P/S: I’m sorry about my bad english, hope you guys understand what i’m talking about.
Thank you.

Regard
Wynix

  • 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-16T05:15:10+00:00Added an answer on May 16, 2026 at 5:15 am

    I have solve the problem and solve it. the erroe is on the xml file. in ListView should NOT have

    android:focusable="true"; menthod.

    anyway Thanks for trying to fix my problem.
    Thanks again.
    Cheers!

    Regard Wynix

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

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
Does anyone know how can I replace this 2 symbol below from the string
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.

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.