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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T07:35:54+00:00 2026-05-16T07:35:54+00:00

ok so i have an array adapted listview (the array adapting is done in

  • 0

ok so i have an array adapted listview (the array adapting is done in another class).. i just got the click listener working for the list but now i want set it up so that when i click an item it pulls the strings from the clicked item and piggybacks them on the intent to a new activity.. i figure im supposed to use intent.putextra however im not sure how to pull the correct strings corresponding to the item that i click on.. my code is below.. im simply lost to be honest

//Initialize the ListView
        lstTest = (ListView)findViewById(R.id.lstText);

         //Initialize the ArrayList
        alrts = new ArrayList<Alerts>();

        //Initialize the array adapter notice with the listitems.xml layout
        arrayAdapter = new AlertsAdapter(this, R.layout.listitems,alrts);

        //Set the above adapter as the adapter for the list
        lstTest.setAdapter(arrayAdapter);

        //Set the click listener for the list
        lstTest.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            public void onItemClick(AdapterView adapterView, View view, int item, long arg3) {
                Intent intent = new Intent(
                        HomePageActivity.this,
                        PromotionActivity.class
                        );
                finish();
                startActivity(intent);
            }
        });

my alerts class..

public class Alerts {

public String cityid;
public String promoterid;
public String promoshortcontent;
public String promocontent;
public String promotitle;
public String locationid;
public String cover;

@Override
public String toString() {
    return "City: " +cityid+ " Promoter: " +promoterid+ "Short Promotion: " +promoshortcontent+ "Promotion: " +promocontent+ "Title: " +promotitle+ "Location: " +locationid+ "Cover: " +cover+ "$";
}

}

anddddd my alertsadapter class..

public class AlertsAdapter extends ArrayAdapter<Alerts> {

int resource;
String response;
Context context;
//Initialize adapter
public AlertsAdapter(Context context, int resource, List<Alerts> items) {
    super(context, resource, items);
    this.resource=resource;

}

@Override
public View getView(int position, View convertView, ViewGroup parent)
{
    LinearLayout alertView;
    //Get the current alert object
    Alerts al = getItem(position);

    //Inflate the view
    if(convertView==null)
    {
        alertView = new LinearLayout(getContext());
        String inflater = Context.LAYOUT_INFLATER_SERVICE;
        LayoutInflater vi;
        vi = (LayoutInflater)getContext().getSystemService(inflater);
        vi.inflate(resource, alertView, true);
    }
    else
    {
        alertView = (LinearLayout) convertView;
    }
    //Get the text boxes from the listitem.xml file
    TextView textPromo =(TextView)alertView.findViewById(R.id.txtPromo);
    TextView textPromoter =(TextView)alertView.findViewById(R.id.txtPromoter);
    TextView textLocation =(TextView)alertView.findViewById(R.id.txtLocation);

    //Assign the appropriate data from our alert object above
    textPromo.setText(al.promocontent);
    textPromoter.setText(al.promoterid);
    textLocation.setText(al.locationid);

    return alertView;
}

}

  • 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-16T07:35:55+00:00Added an answer on May 16, 2026 at 7:35 am

    had an epiphany over the weekend about how to fix this problem and i finally found a good work around for my app.. i know it isnt optimal because i hard coded the number 100 into it but for my uses as of now i know i wont ever have that many list items..

    i added these 2 bits of code to my alertsadapter class

    int startzero = 0;
    
    public static String[][] promomatrix = new String[6][100];
    

    and

    promomatrix[0][startzero] = al.cityid;
    promomatrix[1][startzero] = al.promoterid;
    promomatrix[2][startzero] = al.promocontent;
    promomatrix[3][startzero] = al.promotitle;
    promomatrix[4][startzero] = al.locationid;
    promomatrix[5][startzero] = al.cover;

        startzero++;
    

    then went to my homepageactivity class and added this to the click listener

    Intent intent = new Intent(
                            HomePageActivity.this,PromotionActivity.class);
    
                    intent.putExtra("listitemcity", AlertsAdapter.promomatrix[0][pos]);
                    intent.putExtra("listitempromoter", AlertsAdapter.promomatrix[1][pos]);
                    intent.putExtra("listitemcontent", AlertsAdapter.promomatrix[2][pos]);
                    intent.putExtra("listitemtitle", AlertsAdapter.promomatrix[3][pos]);
                    intent.putExtra("listitemlocation", AlertsAdapter.promomatrix[4][pos]);
                    intent.putExtra("listitemcover", AlertsAdapter.promomatrix[5][pos]);
    
                    finish();
                    startActivity(intent);
    

    and finally went to my promotionactivity (where i was trying to send the strings) and added this

    Bundle extras = getIntent().getExtras();
            if (extras == null){
                return;
            }
            String listitemcity = extras.getString("listitemcity");
            String listitempromoter = extras.getString("listitempromoter");
            String listitemcontent = extras.getString("listitemcontent");
            String listitemtitle = extras.getString("listitemtitle");
            String listitemlocation = extras.getString("listitemlocation");
            String listitemcover = extras.getString("listitemcover");
    

    worked like a charm.. i hope this helps someone 🙂

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

Sidebar

Related Questions

I have a listview connected to a custom array adapter. This list shows information
I have a listview with a custom array adapter: public class SmsMessageAdapter extends ArrayAdapter<ContactMessage>
I have a listview to which i attach data using an Array adapter. But
I have a custom ListView that uses a custom ArrayAdapter (which basically just overrides
I have a listview with custom array adapter, the view allows the user to
In my application, I am using a listview and have customized the associated array
I have a listview NoteList which contains a method doListRefresh() to select list contents
I have searched a lot, but no any solutions are working for me. I
I have used a custom array adapter to populate my list view.The problem i
I have list activity with custom array adapter and I can't to get context

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.