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

  • Home
  • SEARCH
  • 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 8422965
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T03:36:12+00:00 2026-06-10T03:36:12+00:00

It is my mainactivity code. Following is my main activity code and it shows

  • 0

It is my mainactivity code. Following is my main activity code and it shows four errors:

  1. adapter cannot be resolved to a type
  2. Syntax error on token “)”, { expected after this token
  3. Syntax error on token “adapter”, VariableDeclaratorId expected after this token.

Source code:

public class HospitalParseActivity extends ListActivity {
//url where request is made
private static String url="url";

//JSON node names
private static final String TAG_NETFOX="transfer";
private static final String TAG_DATE="date";
private static final String TAG_CWEB="c_web";
private static final String TAG_CBANK="c_bank";
private static final String TAG_CCASH="c_cash";
private static final String TAG_SWEB="s_web";
private static final String TAG_SBANK="s_bank";
private static final String TAG_SCASH="s_cash";

//creation of JSONArray
JSONArray netfoxlimited=null;

private List<? extends Map<String, ?>> contactList;


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

 // Hashmap for ListView
    ArrayList<HashMap<String, String>> contactList = new ArrayList<HashMap<String,         String>>();

    // Creating JSON Parser instance
    JSONParser jParser = new JSONParser();

    // getting JSON string from URL
    JSONObject json = jParser.getJSONFromUrl(url);

    try {
        // Getting Array of Contacts
        netfoxlimited = json.getJSONArray(TAG_NETFOX);

        // looping through All Contacts
        for(int i = 0; i < netfoxlimited.length(); i++){
            JSONObject c = netfoxlimited.getJSONObject(i);

            // Storing each json item in variable
            String date = c.getString(TAG_DATE);
            String c_web = c.getString(TAG_CWEB);
            String c_bank = c.getString(TAG_CBANK);
            String c_cash = c.getString(TAG_CCASH);
            String s_web = c.getString(TAG_SWEB);
            String s_bank = c.getString(TAG_SBANK);
            String s_cash = c.getString(TAG_SCASH);

            // creating new HashMap
            HashMap<String, String> map = new HashMap<String, String>();

            // adding each child node to HashMap key => value
            map.put(TAG_DATE, date);
            map.put(TAG_CWEB, c_web);
            map.put(TAG_CBANK, c_bank);
            map.put(TAG_CCASH, c_cash);
            map.put(TAG_SWEB, s_web);
            map.put(TAG_SBANK, s_bank);
            map.put(TAG_SCASH, s_cash);



            // adding HashList to ArrayList
            contactList.add(map);
        }
    } catch (JSONException e) {
        e.printStackTrace();
    }
}

/**
 * Updating parsed JSON data into ListView
 * */
ListAdapter adapter = new SimpleAdapter(this, contactList,
        R.layout.list_item,
        new String[] { TAG_DATE, TAG_CWEB, TAG_CBANK,TAG_CCASH, TAG_CWEB,TAG_CBANK, TAG_CCASH }, new int[] {
                R.id.date, R.id.cweb, R.id.cbank,R.id.sweb,R.id.sbank,R.id.scash });


setListAdapter(adapter);

// selecting single ListView item
ListView lv = getListView();

// Launching new screen on Selecting Single ListItem
lv.setOnItemClickListener(new OnItemClickListener() {

    @Override
    public void onItemClick(AdapterView<?> parent, View view,
            int position, long id) {
        // getting values from selected ListItem
        String dt = ((TextView) view.findViewById(R.id.date)).getText().toString();
        String web = ((TextView) view.findViewById(R.id.cweb)).getText().toString();
        String bank = ((TextView) view.findViewById(R.id.cbank)).getText().toString();
        String cash = ((TextView) view.findViewById(R.id.ccash)).getText().toString();
        String web1 = ((TextView) view.findViewById(R.id.sweb)).getText().toString();
        String bank1 = ((TextView) view.findViewById(R.id.sbank)).getText().toString();
        String cash1 = ((TextView) view.findViewById(R.id.scash)).getText().toString();


        // Starting new intent
        Intent in = new Intent(getApplicationContext(), SingleMenuItemActivity.class);
        in.putExtra(TAG_DATE, dt);
        in.putExtra(TAG_CWEB, web);
        in.putExtra(TAG_CBANK, bank);
        in.putExtra(TAG_CCASH, cash);
        in.putExtra(TAG_SWEB, web1);
        in.putExtra(TAG_SBANK, bank1);
        in.putExtra(TAG_SCASH, cash1);
        startActivity(in);
    }
});
}

}
  • 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-10T03:36:13+00:00Added an answer on June 10, 2026 at 3:36 am

    Are you writing code outside the onCreate function? Seems like onCreate function ended at the ‘}’ after the catch block. You may just want to remove that

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

Sidebar

Related Questions

I tried using the following code in .java(main activity): final ImageView diskView1 = (ImageView)
The following is my code for SettingsActivity.java. The main activity starts this activity by
I have a main activity that launches a child activity using the following code:
I have the following code which gets call in my main activity's onCreate method
Trying to do the following (code is in the main activity): private MenuItem mainMenuSync
In my main activity, I have the following code that calls my FileBrowser activity:
Say I'm on my main activity and I start a new activity MainActivity >
I have following code that displays an Image with letters, public class MainActivity extends
I have following code: public class readSensorsData extends Activity implements SensorListener { /** Called
I have the following problem. My main activity consists of a ListView populated with

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.