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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T22:55:06+00:00 2026-05-23T22:55:06+00:00

My requirement is : When I click the list row , it need to

  • 0

My requirement is : When I click the list row , it need to go other activity. When I run this code, I got NullPointerException ; (I marked error place in comments)

This is my code:

ArrayList<Object> routeList = getWmRoute();
ArrayList<String> routhPath = new ArrayList<String>();
ArrayList<HashMap<String,String>> alist=new ArrayList<HashMap<String,String>>();

for(int i = 0; i<routeList.size();i++){
    HashMap<String, String> map = new HashMap<String, String>();
    map.put("RetailerCode", ((WMRoute) routeList.get(i)).getDescription());
    map.put("RetailerName", ((WMRoute) routeList.get(i)).getBusinessUnit());
    alist.add(map);
    }

ListView list=getListView();
sd = new SimpleAdapter(this,alist,R.layout.retalier_rows,new String[]{"RetailerCode","RetailerName"},new int[]{R.id.retailerCode,R.id.retailerName});
list.setAdapter(sd);
list.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
list.setSelected(true);
list.setSelection(0);
list.setTextFilterEnabled(true);
list.setItemsCanFocus(true);
list.setTextFilterEnabled(true);
list.setItemChecked(positions,true);
keyword = ((WMRoute) routeList.get(0)).getBusinessUnit(); // here Problem 1 place
//keyword = (String) list.getItemAtPosition(0); // here Problem 1 place

This is my listener part:

 @Override


  protected void onListItemClick(ListView l, View v, int position, long id) {
        super.onListItemClick(l, v, position, id);
        Object o = this.getListAdapter().getItem(position); //java.lang.NullPointerException -  problem here 2nd place
        keyword = o.toString(); // have to get first column value
        positions = position;
        if(position != 0 ){
            Bundle bundle = new Bundle();
            Intent showContent = new Intent(getApplicationContext(),RetailerOptionActivity.class);
            int postion = position;
            String aString = Integer.toString(postion);
            bundle.putString("positon", aString);
             startActivity(showContent);

        }
    }

When I click “OK” from menu option , I am setting parameters;

  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
        case 0:
            Intent showContent = new Intent(getApplicationContext(),RetailerOptionActivity.class);
            Bundle bundle = new Bundle();
            bundle.putString("RetailerName", keyword);
            showContent.putExtras(bundle);
             startActivity(showContent);
            return true;
        case 1:
            return true;
        default:
            return super.onOptionsItemSelected(item);
        }
    }

This is my another activity:

Bundle bundle = this.getIntent().getExtras();
String RetailerName = bundle.getString("RetailerName");

setTitle(RetailerName + " - Retailer Option"); // want to get the parameter & set the title name

I have to set the title name , which is picked from previous list option clicked(selected first column name) .

Please help me..

Thanks in advance.

  • 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-23T22:55:07+00:00Added an answer on May 23, 2026 at 10:55 pm

    In your onListItemClick() event, instead of using this.getListAdapter().getItem(position) to get the value of the first column in the item, you should use the View v, given to you as an argument to the event, to get the view that represents the first column. For example, if the first column is a textview, you should do the following:

    TextView tv = (TextView)v.findViewById(R.id.firstColumnTextView);
    keyword = tv.getText();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My requirement is One activity is calling another activity.When I click the radio button
Requirement is this ... We have our 3 web-applications deployed in RHEL-5 server, we
My requirement A table needs to maintain a status column. This column represents one
I am looking for the right UI widget to use for this requirement: When
Hello Friends I want to upload a image but according to requirement when click
My Requirement is whenever I click on the Extension Icon that should send a
Possible Duplicate: UITableView Cell expand on click i need help in UITableViewCell of UITableView.My
I got a new requirement from the business about real time data/statistics. They want
I'm currently working on a Flex3/blazeDS/Spring/Oracle project. My requirement is display a list of
I have a requirement that when the user clicks on [X] button of the

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.