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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T06:21:01+00:00 2026-06-17T06:21:01+00:00

So I have a ListView that is being populated from a web served xml

  • 0

So I have a ListView that is being populated from a web served xml file. The list populates fine. Well, it uses a bad method to populate, I know it should use an AsyncTask but instead it populates on the UI thread. I tried and tried with an AsyncTask, but I lost the fight! I know I know!! If you have a solution to that Id love to hear it!!
Anyways, when a list item is clicked, Im starting a new activity and passing the info using intent.putExtra
This works, but it always shows the info from the first item in the list.
Example:

A

B

C

D

E

are items in a list. Pressing any one of them gives me all the info pertaining to A in the following activity
How do I fix this???

ListView Activity:

    public class ColorPacksMain extends Activity {
// All static variables
static final String URL = "https://dl.dropbox.com/u/43058382/BeanPickerColorToolUpdates/ColorPacksList.xml";
// XML node keys
static final String KEY_COLORPACK = "ColorPack"; // parent node
static final String KEY_ID = "id";
static final String KEY_USER = "user";
static final String KEY_THEME = "theme";
static final String KEY_THEMECOLOR = "themeColor";
static final String KEY_TEXTCOLORPRIMARY = "primaryTextColor";
static final String KEY_TEXTCOLORSECONDARY = "secondaryTextColor";
static final String KEY_THUMB_URL = "thumb_url";
static final String KEY_DL_URL_GSM = "dl_url_gsm";
static final String KEY_DL_URL_LTE = "dl_url_lte";
static final String KEY_SCREEN1 = "screen1";
static final String KEY_SCREEN2 = "screen2";
static final String KEY_SCREEN3 = "screen3";
static final String KEY_SCREEN4 = "screen4";

ListView list;
LazyAdapter adapter;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.color_packs_activity);

    StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();

    StrictMode.setThreadPolicy(policy);


    ArrayList<HashMap<String, String>> colorPacksList = new ArrayList<HashMap<String, String>>();

    XMLParser parser = new XMLParser();
    String xml = parser.getXmlFromUrl(URL); // getting XML from URL
    Document doc = parser.getDomElement(xml); // getting DOM element

    NodeList nl = doc.getElementsByTagName(KEY_COLORPACK);
    // looping through all song nodes <song>
    for (int i = 0; i < nl.getLength(); i++) {
        // creating new HashMap
        HashMap<String, String> map = new HashMap<String, String>();
        Element e = (Element) nl.item(i);
        // adding each child node to HashMap key => value
        map.put(KEY_ID, parser.getValue(e, KEY_ID));
        map.put(KEY_USER, parser.getValue(e, KEY_USER));
        map.put(KEY_THEME, parser.getValue(e, KEY_THEME));
        map.put(KEY_THEMECOLOR, parser.getValue(e, KEY_THEMECOLOR));
        map.put(KEY_TEXTCOLORPRIMARY, parser.getValue(e, KEY_TEXTCOLORPRIMARY));
        map.put(KEY_TEXTCOLORSECONDARY, parser.getValue(e, KEY_TEXTCOLORSECONDARY));
        map.put(KEY_DL_URL_GSM, parser.getValue(e, KEY_DL_URL_GSM));
        map.put(KEY_DL_URL_LTE, parser.getValue(e, KEY_DL_URL_LTE));
        map.put(KEY_SCREEN1, parser.getValue(e, KEY_SCREEN1));
        map.put(KEY_SCREEN2, parser.getValue(e, KEY_SCREEN2));
        map.put(KEY_SCREEN3, parser.getValue(e, KEY_SCREEN3));
        map.put(KEY_SCREEN4, parser.getValue(e, KEY_SCREEN4));
        map.put(KEY_THUMB_URL, parser.getValue(e, KEY_THUMB_URL));

        // adding HashList to ArrayList
        colorPacksList.add(map);
    }


    list = (ListView) findViewById(R.id.colorPacksList);

    // Getting adapter by passing xml data ArrayList
    adapter=new LazyAdapter(this, colorPacksList);        
    list.setAdapter(adapter);


    // Click event for single list row
    list.setOnItemClickListener(new OnItemClickListener() {


        @Override

        public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
                long arg3) {
              // Launching new Activity on selecting single List Item
              Intent i = new Intent(getApplicationContext(), ListClickedItem.class);
              // sending data to new activity
              String user = ((TextView) findViewById(R.id.user)).getText().toString();
              String theme = ((TextView) findViewById(R.id.theme)).getText().toString();
              String themeColor = ((TextView) findViewById(R.id.themeColor)).getText().toString();
              String tcP = ((TextView) findViewById(R.id.primaryTextColor)).getText().toString();
              String tcS = ((TextView) findViewById(R.id.secondaryTextColor)).getText().toString();
              String dlGSM = ((TextView) findViewById(R.id.GSMurl)).getText().toString();
              String dlLTE = ((TextView) findViewById(R.id.LTEurl)).getText().toString();
              String screen1 = ((TextView) findViewById(R.id.screen1url)).getText().toString();
              String screen2 = ((TextView) findViewById(R.id.screen2url)).getText().toString();
              String screen3 = ((TextView) findViewById(R.id.screen3url)).getText().toString();
              String screen4 = ((TextView) findViewById(R.id.screen4url)).getText().toString();
              i.putExtra("UserName", user);
              i.putExtra("ThemeName", theme);
              i.putExtra("ThemeColor", themeColor);
              i.putExtra("TextColorPrimary", tcP);
              i.putExtra("TextColorSecondary", tcS);
              i.putExtra("GSM", dlGSM);
              i.putExtra("LTE", dlLTE);
              i.putExtra("Screenshot 1", screen1);
              i.putExtra("Screenshot 2", screen2);
              i.putExtra("Screenshot 3", screen3);
              i.putExtra("Screenshot 4", screen4);
              startActivity(i);

        }
    });     
}   

The Activity that is displayed after an item is clicked:

    public class ListClickedItem extends Activity{
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.setContentView(R.layout.list_clicked_activity);


    TextView txtUser = (TextView) findViewById(R.id.userName);
    TextView txtTheme = (TextView) findViewById(R.id.themeName);
    TextView txtThemeColor = (TextView) findViewById(R.id.themeColor);
    TextView txtColor1 = (TextView) findViewById(R.id.textColor1);
    TextView txtColor2 = (TextView) findViewById(R.id.textColor2);
    TextView txtLTEurl = (TextView) findViewById(R.id.lteUrl);
    TextView txtGSMurl = (TextView) findViewById(R.id.gsmUrl);

    ImageView screenShot1 = (ImageView) findViewById(R.id.screen1);
    ImageView screenShot2 = (ImageView) findViewById(R.id.screen2);
    ImageView screenShot3 = (ImageView) findViewById(R.id.screen3);
    ImageView screenShot4 = (ImageView) findViewById(R.id.screen4);

    Bundle extras = getIntent().getExtras();
    if(extras!=null){
        String user=extras.getString("UserName");
        String themeName=extras.getString("ThemeName");
        String themeColor=extras.getString("ThemeColor");
        String tcPrimary=extras.getString("TextColorPrimary");
        String tcSecondary=extras.getString("TextColorSecondary");
        String linkGsm=extras.getString("GSM");
        String linkLte=extras.getString("LTE");
        String screen1=extras.getString("Screenshot 1");
        String screen2=extras.getString("Screenshot 2");
        String screen3=extras.getString("Screenshot 3");
        String screen4=extras.getString("Screenshot 4");

        txtUser.setText("User Name: " + user);
        txtTheme.setText("Theme Name: " + themeName);
        txtThemeColor.setText("Theme Color: " + themeColor);
        txtColor1.setText("Primary Text Color: " + tcPrimary);
        txtColor2.setText("Secondary Text Color: " + tcSecondary);
        txtLTEurl.setText(linkLte);
        txtGSMurl.setText(linkGsm);

        Drawable s1;
        try {
            InputStream is = (InputStream) new URL(screen1).getContent();
            s1 = Drawable.createFromStream(is, "src name");
            screenShot1.setBackgroundDrawable(s1);
        } catch (Exception e) {

        }

        Drawable s2;
        try {
            InputStream is = (InputStream) new URL(screen2).getContent();
            s2 = Drawable.createFromStream(is, "src name");
            screenShot2.setBackgroundDrawable(s2);
        } catch (Exception e) {

        }

        Drawable s3;
        try {
            InputStream is = (InputStream) new URL(screen3).getContent();
            s3 = Drawable.createFromStream(is, "src name");
            screenShot3.setBackgroundDrawable(s3);
        } catch (Exception e) {

        }

        Drawable s4;
        try {
            InputStream is = (InputStream) new URL(screen4).getContent();
            s4 = Drawable.createFromStream(is, "src name");
            screenShot4.setBackgroundDrawable(s4);
        } catch (Exception e) {

        }

    }

}

And, my Adapter class, becuase I know it will be asked for:

    public class LazyAdapter extends BaseAdapter {

private Activity activity;
private ArrayList<HashMap<String, String>> data;
private static LayoutInflater inflater=null;
public ImageLoader imageLoader; 

public LazyAdapter(Activity a, ArrayList<HashMap<String, String>> d) {
    activity = a;
    data=d;
    inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    imageLoader=new ImageLoader(activity.getApplicationContext());
}

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

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

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

public View getView(int position, View convertView, ViewGroup parent) {
    View vi=convertView;
    if(convertView==null)
        vi = inflater.inflate(R.layout.list_row, null);

    TextView user = (TextView)vi.findViewById(R.id.user); // username
    TextView theme = (TextView)vi.findViewById(R.id.theme); // theme name
    TextView themeColor = (TextView)vi.findViewById(R.id.themeColor); // theme color
    TextView primaryTextColor = (TextView)vi.findViewById(R.id.primaryTextColor); // main text color
    TextView secondaryTextColor = (TextView)vi.findViewById(R.id.secondaryTextColor); // secondary text color
    TextView gsmURL = (TextView)vi.findViewById(R.id.GSMurl); // Maguro URL
    TextView lteURL = (TextView)vi.findViewById(R.id.LTEurl); // Toro/ToroPlus URL
    TextView screenShot1 = (TextView)vi.findViewById(R.id.screen1url); // Screenshot url
    TextView screenShot2 = (TextView)vi.findViewById(R.id.screen2url); // Screenshot url
    TextView screenShot3 = (TextView)vi.findViewById(R.id.screen3url); // Screenshot url
    TextView screenShot4 = (TextView)vi.findViewById(R.id.screen4url); // Screenshot url
    ImageView thumb_image=(ImageView)vi.findViewById(R.id.list_image); // thumb image

    HashMap<String, String> colorPack = new HashMap<String, String>();
    colorPack = data.get(position);

    // Setting all values in listview
    user.setText(colorPack.get(ColorPacksMain.KEY_USER));
    theme.setText(colorPack.get(ColorPacksMain.KEY_THEME));
    themeColor.setText(colorPack.get(ColorPacksMain.KEY_THEMECOLOR));
    primaryTextColor.setText(colorPack.get(ColorPacksMain.KEY_TEXTCOLORPRIMARY));
    secondaryTextColor.setText(colorPack.get(ColorPacksMain.KEY_TEXTCOLORSECONDARY));
    gsmURL.setText(colorPack.get(ColorPacksMain.KEY_DL_URL_GSM));
    lteURL.setText(colorPack.get(ColorPacksMain.KEY_DL_URL_LTE));
    screenShot1.setText(colorPack.get(ColorPacksMain.KEY_SCREEN1));
    screenShot2.setText(colorPack.get(ColorPacksMain.KEY_SCREEN2));
    screenShot3.setText(colorPack.get(ColorPacksMain.KEY_SCREEN3));
    screenShot4.setText(colorPack.get(ColorPacksMain.KEY_SCREEN4));
    imageLoader.DisplayImage(colorPack.get(ColorPacksMain.KEY_THUMB_URL), thumb_image);
    return vi;
}

Any help is greatly appreciated!

  • 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-17T06:21:02+00:00Added an answer on June 17, 2026 at 6:21 am

    write view.findViewById in everyline. just like below.

     public void onItemClick(AdapterView<?> arg0, View view, int arg2,
                long arg3) {
              // Launching new Activity on selecting single List Item
              Intent i = new Intent(getApplicationContext(), ListClickedItem.class);
    
              // sending data to new activity
    
              String user = ((TextView) view.findViewById(R.id.user)).getText().toString();
              String theme = ((TextView) view.findViewById(R.id.theme)).getText().toString();
    
              startActivity(i);
    
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a listview that is being populated by information from a database using
I have created a custom listview that is populated using a row.xml file. Each
I am using a listView that is being populated from a database. I know
I have a ListView that is being populated with a custom adapter. I have
I have a ListView that is being populated with a custom adapter. I'd like
I have a listView that is being updated from multiple threads, with the threads
I have a list of adverts that is being populated by a custom cursoradapter.
I have a ListView template that's being used in several places and I'd like
I have ListView that uses a GridView to display several columns of data. Two
I have a ListView that displays a shopping cart. It was working fine until

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.