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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T23:47:41+00:00 2026-05-31T23:47:41+00:00

Im looking to run a query on my external database, i got all the

  • 0

Im looking to run a query on my external database, i got all the coding done up to this point. Although the coding works, I need it to put the “name” and the “cphone” in an array of some sort so i can add it to the custom list adapter as a double row.

”””””””””””””””””’

name

”””””””””””””””””’

cphone

”””””””””””””””””’

to this

”””””””””””””””””’

name cphone

”””””””””””””””””’

Log.d("RESULT", result);

        try {
            JSONArray jArray = new JSONArray(result);
            ArrayList<String> items = new ArrayList<String>();
            for (int i = 0; i < jArray.length(); i++) {
                JSONObject json_data = jArray.getJSONObject(i);
                String name = json_data.getString("username");
                String cphone = json_data.getString("password");
                items.add(name);
                items.add(cphone);
                Log.d(name, "Sever Output");
            }

            ArrayAdapter<String> mArrayAdapter = new ArrayAdapter<String>(
                    getdata.this, R.layout.stashrow, items);
            ListView sList = (ListView) findViewById(R.id.liststash);
            sList.setAdapter(mArrayAdapter);

        } catch (Exception e) {
            Log.e("errorLog", "Error makingView: " + e.toString());
        }

the problem stands in the item.add(), i can only put one value in at a time so it makes it 2 different lines. If I try adding another textview to the stashrow, it errors out. Is there a better way of doing this?

  • 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-31T23:47:42+00:00Added an answer on May 31, 2026 at 11:47 pm

    The basic ArrayAdapter isn’t configured to do very much. If you’re content with the simple formatting of
    ”””””””””””””””””’

    name cphone

    ”””””””””””””””””’

    Then you might as well just concatenate the strings together:

    String name = json_data.getString("username");
    String cphone = json_data.getString("password");
    String user = name + " " + cphone;
    items.add(user);
    

    For anything more complicated then that, you’re better off defining your own data object (like a User for instance, with a getName() and getCPhone()) and then subclassing ArrayAdapter to translate the objects in the array into the well formatted ListView you really want – like so:

    public class MyAdapter extends ArrayAdapter<User> {
    // Constructor, etc
    ...
    @Override
    public void getView(int position, View convertView, ViewGroup parent) {
    
      View view = convertView;
      if (view == null) {
        final LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(
            Context.LAYOUT_INFLATER_SERVICE);
        view = inflater.inflate(R.layout.stashrow, null);
      }
      User user = items.get(position)
      TextView name = (TextView) findViewById(R.id.stash_row_name);
      TextView chpone = (TextView) findViewById(R.id.stash_row_cphone);
      name.setText(user.getName());
      cphone.setText(user.getCPhone());
    }
    

    Hope that helps!

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

Sidebar

Related Questions

Looking to run a query using multiple left joins. The following query works. SELECT
I can run this query to get the sizes of all tables in a
I am looking into using only a ddl to run my query, not a
I'm looking for small utility to run on windows mobile phone and trace all
I run a query against a MySQL database to get total number of visits
I'm looking to run a query that will return a list of columns in
I'm looking to run Redmine, a Ruby on Rails app, on a VPS windows
I'm looking to run a Jabber server on a Windows 2003 server(web farm) and
I'm looking to run some un-verified scripts (written in a yet-to-be-determined language, but needs
We are looking to run a large amount of data through some unit tests.

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.