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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T03:26:06+00:00 2026-06-16T03:26:06+00:00

Possible Duplicate: Adapter for a custom layout of listview ArrayAdapter<String> adapter = null; JSONArray

  • 0

Possible Duplicate:
Adapter for a custom layout of listview

ArrayAdapter<String> adapter = null;
JSONArray productsList = null;
try {
    productsList = obj5.getJSONArray("Content");
} catch (JSONException e2) {
    e2.printStackTrace();
}

if(productsList != null){
    ListView lv = (ListView) findViewById(android.R.id.list);

    for (int i=0; i<productsList.length(); i++) {

    final String[] items = new String[productsList.length()]; 

    String product = null;

    try {       
        product = productsList.getJSONObject(i).getString("Quantity")+" X "+
            productsList.getJSONObject(i).getString("Name") +"         "+
            Currency.britishPound+productsList.getJSONObject(i).getString("MinCost");
    } catch (JSONException e) {
        e.printStackTrace();
    }

    if(product!=null){                  
        items[i]=product;                       
    }

    adapter = new ArrayAdapter<String>(APIQuickCheckout.this, R.layout.product_item, R.id.label, items);

    lv.setAdapter(adapter);
}

Here is my list view:

<ListView
    android:id="@android:id/list"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_margin="5dip"
    android:layout_weight="30">
</ListView>

And here is how I pass each product seperately.

<?xml version="1.0" encoding="utf-8"?>
<!--  Single List Item Design -->
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/label"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:padding="10dip"
    android:textSize="16sp"
    android:textStyle="bold" >
 </TextView>

Now and according to the the aforementioned code I’m passing to each line just a simple string. However, I was wondering how could I pass three different Strings. The reason that I want to pass three different Strings is that I want them to be in the following format:

Quantity X 
Number                          Price(this should be at the end of the line)
  • 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-16T03:26:08+00:00Added an answer on June 16, 2026 at 3:26 am

    You have to derive from adapter, and provide properly filled views. Like here:

    https://github.com/ko5tik/camerawatch/blob/master/src/de/pribluda/android/camerawatch/CameraAdapter.java

    For better performance consider:

    • reusing views supplied to getView() method#
    • utilise viewHolder patern to save getViewById() resolution
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Crash on ListView.removeFooterView(View) How is it possible to get a null pointer
Possible Duplicate: C++ convert int and string to char* Hello, i am making a
Possible Duplicate: IErrorInfo.GetDescription failed with E_FAIL(0x80004005).System.Data while data adapter Fill() Below is the code
Possible Duplicate: What's the @ in front of a string in C#? This is
Possible Duplicate: MD5 algorithm in Objective C I need to hash a string using
Possible Duplicate: Parsing XML String in C# How to process the below XML file
Possible Duplicate: Find the “#” character in a string with Javascript How do I
Possible Duplicate: how to clear my listview in android In android, i have used
Possible Duplicate: php string escaping like python’s ? The triple-quotes in python escapes all
Possible Duplicate: wordwrap a very long string My code <div style=width:40px;>adfdddddddddddddddddddd</div> This code should

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.