parse json in custom list view base adapter
up vote
0
down vote
favorite
public class YourAdvertisement extends AppCompatActivity {
ArrayList<String> items = new ArrayList<String>();
String date = null;
String price = null;
String type2 = null;
String amount = null;
ListView listView;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String url =uid + "&access_token=" + access_token + "&start=" + start + "&total=" + total + "&type=" + type + "&signature=" + hashkey;
StringRequest request = new StringRequest(Request.Method.POST, url, new Response.Listener<String>() {
@Override
public void onResponse(String s) {
// s is the response from the server
//if success go to login page
if (s.contains("{"status_code":100,""))
{
try {
JSONObject json = new JSONObject(s);
JSONArray leaders= json.getJSONArray("listing");
// ArrayList<String> items = new ArrayList<String>();
for(int i=0;i<leaders.length(); i++){
JSONObject jsonas = leaders.getJSONObject(i);
date = jsonas.getString("date");
price = jsonas.getString("price");
type2 = jsonas.getString("type");
amount = jsonas.getString("amount");
items.add(date);
Log.d(date,"Output");
}
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
ArrayAdapter<String> mArrayAdapter = new ArrayAdapter<String>(YourAdvertisement.this, android.R.layout.simple_expandable_list_item_1, items);
listView.setAdapter(customAdapter);
Intent intent = new Intent(YourAdvertisement.this, Tabbed.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError volleyError) {
Toast.makeText(YourAdvertisement.this, "Some error occurred -> " + volleyError, Toast.LENGTH_LONG).show();
//This is to hide the keyboard
InputMethodManager imm = (InputMethodManager) getSystemService(Activity.INPUT_METHOD_SERVICE);
imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);
}
});
RequestQueue requestQueue = Volley.newRequestQueue(YourAdvertisement.this);
requestQueue.add(request);
}
class CustomAdapter extends BaseAdapter {
@Override
public int getCount() {
return date.length();
}
@Override
public Object getItem(int position) {
return null;
}
@Override
public long getItemId(int position) {
return 0;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
convertView = getLayoutInflater().inflate(R.layout.adapter_view_layout,null);
TextView buyTextView = (TextView)convertView.findViewById(R.id.buyTextView);
TextView buyValueTextView = (TextView)convertView.findViewById(R.id.buyValueTextView);
TextView timeTextView = (TextView)convertView.findViewById(R.id.timeTextView);
return convertView;
}
}
}
how to parse json into base adapter custom list view ? Here is my code.Can anyone correctmy code?thank and appreciate .how to parse json into base adapter custom list view ? Here is my code.Can anyone correctmy code?thank and appreciate .how to parse json into base adapter custom list view ? Here is my code.Can anyone correctmy code?thank and appreciate .how to parse json into base adapter custom list view ? Here is my code.Can anyone correctmy code?thank and appreciate .how to parse json into base adapter custom list view ? Here is my code.Can anyone correctmy code?thank and appreciate .how to parse json into base adapter custom list view ? Here is my code.Can anyone correctmy code?thank and appreciate .how to parse json into base adapter custom list view ? Here is my code.Can anyone correctmy code?thank and appreciate .how to parse json into base adapter custom list view ? Here is my code.Can anyone correctmy code?thank and appreciate .how to parse json into base adapter custom list view ? Here is my code.Can anyone correctmy code?thank and appreciate .how to parse json into base adapter custom list view ? Here is my code.Can anyone correctmy code?thank and appreciate .how to parse json into base adapter custom list view ? Here is my code.Can anyone correctmy code?thank and appreciate .how to parse json into base adapter custom list view ? Here is my code.Can anyone correctmy code?thank and appreciate .how to parse json into base adapter custom list view ? Here is my code.Can anyone correctmy code?thank and appreciate .how to parse json into base adapter custom list view ? Here is my code.Can anyone correctmy code?thank and appreciate .how to parse json into base adapter custom list view ? Here is my code.Can anyone correctmy code?thank and appreciate .how to parse json into base adapter custom list view ? Here is my code.Can anyone correctmy code?thank and appreciate .how to parse json into base adapter custom list view ? Here is my code.Can anyone correctmy code?thank and appreciate .how to parse json into base adapter custom list view ? Here is my code.Can anyone correctmy code?thank and appreciate .how to parse json into base adapter custom list view ? Here is my code.Can anyone correctmy code?thank and appreciate .how to parse json into base adapter custom list view ? Here is my code.Can anyone correctmy code?thank and appreciate .how to parse json into base adapter custom list view ? Here is my code.Can anyone correctmy code?thank and appreciate .how to parse json into base adapter custom list view ? Here is my code.Can anyone correctmy code?thank and appreciate .
android
|
show 1 more comment
up vote
0
down vote
favorite
public class YourAdvertisement extends AppCompatActivity {
ArrayList<String> items = new ArrayList<String>();
String date = null;
String price = null;
String type2 = null;
String amount = null;
ListView listView;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String url =uid + "&access_token=" + access_token + "&start=" + start + "&total=" + total + "&type=" + type + "&signature=" + hashkey;
StringRequest request = new StringRequest(Request.Method.POST, url, new Response.Listener<String>() {
@Override
public void onResponse(String s) {
// s is the response from the server
//if success go to login page
if (s.contains("{"status_code":100,""))
{
try {
JSONObject json = new JSONObject(s);
JSONArray leaders= json.getJSONArray("listing");
// ArrayList<String> items = new ArrayList<String>();
for(int i=0;i<leaders.length(); i++){
JSONObject jsonas = leaders.getJSONObject(i);
date = jsonas.getString("date");
price = jsonas.getString("price");
type2 = jsonas.getString("type");
amount = jsonas.getString("amount");
items.add(date);
Log.d(date,"Output");
}
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
ArrayAdapter<String> mArrayAdapter = new ArrayAdapter<String>(YourAdvertisement.this, android.R.layout.simple_expandable_list_item_1, items);
listView.setAdapter(customAdapter);
Intent intent = new Intent(YourAdvertisement.this, Tabbed.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError volleyError) {
Toast.makeText(YourAdvertisement.this, "Some error occurred -> " + volleyError, Toast.LENGTH_LONG).show();
//This is to hide the keyboard
InputMethodManager imm = (InputMethodManager) getSystemService(Activity.INPUT_METHOD_SERVICE);
imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);
}
});
RequestQueue requestQueue = Volley.newRequestQueue(YourAdvertisement.this);
requestQueue.add(request);
}
class CustomAdapter extends BaseAdapter {
@Override
public int getCount() {
return date.length();
}
@Override
public Object getItem(int position) {
return null;
}
@Override
public long getItemId(int position) {
return 0;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
convertView = getLayoutInflater().inflate(R.layout.adapter_view_layout,null);
TextView buyTextView = (TextView)convertView.findViewById(R.id.buyTextView);
TextView buyValueTextView = (TextView)convertView.findViewById(R.id.buyValueTextView);
TextView timeTextView = (TextView)convertView.findViewById(R.id.timeTextView);
return convertView;
}
}
}
how to parse json into base adapter custom list view ? Here is my code.Can anyone correctmy code?thank and appreciate .how to parse json into base adapter custom list view ? Here is my code.Can anyone correctmy code?thank and appreciate .how to parse json into base adapter custom list view ? Here is my code.Can anyone correctmy code?thank and appreciate .how to parse json into base adapter custom list view ? Here is my code.Can anyone correctmy code?thank and appreciate .how to parse json into base adapter custom list view ? Here is my code.Can anyone correctmy code?thank and appreciate .how to parse json into base adapter custom list view ? Here is my code.Can anyone correctmy code?thank and appreciate .how to parse json into base adapter custom list view ? Here is my code.Can anyone correctmy code?thank and appreciate .how to parse json into base adapter custom list view ? Here is my code.Can anyone correctmy code?thank and appreciate .how to parse json into base adapter custom list view ? Here is my code.Can anyone correctmy code?thank and appreciate .how to parse json into base adapter custom list view ? Here is my code.Can anyone correctmy code?thank and appreciate .how to parse json into base adapter custom list view ? Here is my code.Can anyone correctmy code?thank and appreciate .how to parse json into base adapter custom list view ? Here is my code.Can anyone correctmy code?thank and appreciate .how to parse json into base adapter custom list view ? Here is my code.Can anyone correctmy code?thank and appreciate .how to parse json into base adapter custom list view ? Here is my code.Can anyone correctmy code?thank and appreciate .how to parse json into base adapter custom list view ? Here is my code.Can anyone correctmy code?thank and appreciate .how to parse json into base adapter custom list view ? Here is my code.Can anyone correctmy code?thank and appreciate .how to parse json into base adapter custom list view ? Here is my code.Can anyone correctmy code?thank and appreciate .how to parse json into base adapter custom list view ? Here is my code.Can anyone correctmy code?thank and appreciate .how to parse json into base adapter custom list view ? Here is my code.Can anyone correctmy code?thank and appreciate .how to parse json into base adapter custom list view ? Here is my code.Can anyone correctmy code?thank and appreciate .how to parse json into base adapter custom list view ? Here is my code.Can anyone correctmy code?thank and appreciate .how to parse json into base adapter custom list view ? Here is my code.Can anyone correctmy code?thank and appreciate .
android
You are initializing an ArrayAdapter, then using an uninitialized customAdapter.
– lionscribe
Nov 5 at 2:41
@lionscribe can you share the code?
– Sze Ko
Nov 5 at 2:51
You need to initialize listView also before access that
– Ashish Singhal
Nov 5 at 4:01
First get it working with static text, then worry about json.
– lionscribe
Nov 5 at 4:32
can someone correct my code?
– Sze Ko
Nov 5 at 4:45
|
show 1 more comment
up vote
0
down vote
favorite
up vote
0
down vote
favorite
public class YourAdvertisement extends AppCompatActivity {
ArrayList<String> items = new ArrayList<String>();
String date = null;
String price = null;
String type2 = null;
String amount = null;
ListView listView;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String url =uid + "&access_token=" + access_token + "&start=" + start + "&total=" + total + "&type=" + type + "&signature=" + hashkey;
StringRequest request = new StringRequest(Request.Method.POST, url, new Response.Listener<String>() {
@Override
public void onResponse(String s) {
// s is the response from the server
//if success go to login page
if (s.contains("{"status_code":100,""))
{
try {
JSONObject json = new JSONObject(s);
JSONArray leaders= json.getJSONArray("listing");
// ArrayList<String> items = new ArrayList<String>();
for(int i=0;i<leaders.length(); i++){
JSONObject jsonas = leaders.getJSONObject(i);
date = jsonas.getString("date");
price = jsonas.getString("price");
type2 = jsonas.getString("type");
amount = jsonas.getString("amount");
items.add(date);
Log.d(date,"Output");
}
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
ArrayAdapter<String> mArrayAdapter = new ArrayAdapter<String>(YourAdvertisement.this, android.R.layout.simple_expandable_list_item_1, items);
listView.setAdapter(customAdapter);
Intent intent = new Intent(YourAdvertisement.this, Tabbed.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError volleyError) {
Toast.makeText(YourAdvertisement.this, "Some error occurred -> " + volleyError, Toast.LENGTH_LONG).show();
//This is to hide the keyboard
InputMethodManager imm = (InputMethodManager) getSystemService(Activity.INPUT_METHOD_SERVICE);
imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);
}
});
RequestQueue requestQueue = Volley.newRequestQueue(YourAdvertisement.this);
requestQueue.add(request);
}
class CustomAdapter extends BaseAdapter {
@Override
public int getCount() {
return date.length();
}
@Override
public Object getItem(int position) {
return null;
}
@Override
public long getItemId(int position) {
return 0;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
convertView = getLayoutInflater().inflate(R.layout.adapter_view_layout,null);
TextView buyTextView = (TextView)convertView.findViewById(R.id.buyTextView);
TextView buyValueTextView = (TextView)convertView.findViewById(R.id.buyValueTextView);
TextView timeTextView = (TextView)convertView.findViewById(R.id.timeTextView);
return convertView;
}
}
}
how to parse json into base adapter custom list view ? Here is my code.Can anyone correctmy code?thank and appreciate .how to parse json into base adapter custom list view ? Here is my code.Can anyone correctmy code?thank and appreciate .how to parse json into base adapter custom list view ? Here is my code.Can anyone correctmy code?thank and appreciate .how to parse json into base adapter custom list view ? Here is my code.Can anyone correctmy code?thank and appreciate .how to parse json into base adapter custom list view ? Here is my code.Can anyone correctmy code?thank and appreciate .how to parse json into base adapter custom list view ? Here is my code.Can anyone correctmy code?thank and appreciate .how to parse json into base adapter custom list view ? Here is my code.Can anyone correctmy code?thank and appreciate .how to parse json into base adapter custom list view ? Here is my code.Can anyone correctmy code?thank and appreciate .how to parse json into base adapter custom list view ? Here is my code.Can anyone correctmy code?thank and appreciate .how to parse json into base adapter custom list view ? Here is my code.Can anyone correctmy code?thank and appreciate .how to parse json into base adapter custom list view ? Here is my code.Can anyone correctmy code?thank and appreciate .how to parse json into base adapter custom list view ? Here is my code.Can anyone correctmy code?thank and appreciate .how to parse json into base adapter custom list view ? Here is my code.Can anyone correctmy code?thank and appreciate .how to parse json into base adapter custom list view ? Here is my code.Can anyone correctmy code?thank and appreciate .how to parse json into base adapter custom list view ? Here is my code.Can anyone correctmy code?thank and appreciate .how to parse json into base adapter custom list view ? Here is my code.Can anyone correctmy code?thank and appreciate .how to parse json into base adapter custom list view ? Here is my code.Can anyone correctmy code?thank and appreciate .how to parse json into base adapter custom list view ? Here is my code.Can anyone correctmy code?thank and appreciate .how to parse json into base adapter custom list view ? Here is my code.Can anyone correctmy code?thank and appreciate .how to parse json into base adapter custom list view ? Here is my code.Can anyone correctmy code?thank and appreciate .how to parse json into base adapter custom list view ? Here is my code.Can anyone correctmy code?thank and appreciate .how to parse json into base adapter custom list view ? Here is my code.Can anyone correctmy code?thank and appreciate .
android
public class YourAdvertisement extends AppCompatActivity {
ArrayList<String> items = new ArrayList<String>();
String date = null;
String price = null;
String type2 = null;
String amount = null;
ListView listView;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String url =uid + "&access_token=" + access_token + "&start=" + start + "&total=" + total + "&type=" + type + "&signature=" + hashkey;
StringRequest request = new StringRequest(Request.Method.POST, url, new Response.Listener<String>() {
@Override
public void onResponse(String s) {
// s is the response from the server
//if success go to login page
if (s.contains("{"status_code":100,""))
{
try {
JSONObject json = new JSONObject(s);
JSONArray leaders= json.getJSONArray("listing");
// ArrayList<String> items = new ArrayList<String>();
for(int i=0;i<leaders.length(); i++){
JSONObject jsonas = leaders.getJSONObject(i);
date = jsonas.getString("date");
price = jsonas.getString("price");
type2 = jsonas.getString("type");
amount = jsonas.getString("amount");
items.add(date);
Log.d(date,"Output");
}
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
ArrayAdapter<String> mArrayAdapter = new ArrayAdapter<String>(YourAdvertisement.this, android.R.layout.simple_expandable_list_item_1, items);
listView.setAdapter(customAdapter);
Intent intent = new Intent(YourAdvertisement.this, Tabbed.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError volleyError) {
Toast.makeText(YourAdvertisement.this, "Some error occurred -> " + volleyError, Toast.LENGTH_LONG).show();
//This is to hide the keyboard
InputMethodManager imm = (InputMethodManager) getSystemService(Activity.INPUT_METHOD_SERVICE);
imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);
}
});
RequestQueue requestQueue = Volley.newRequestQueue(YourAdvertisement.this);
requestQueue.add(request);
}
class CustomAdapter extends BaseAdapter {
@Override
public int getCount() {
return date.length();
}
@Override
public Object getItem(int position) {
return null;
}
@Override
public long getItemId(int position) {
return 0;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
convertView = getLayoutInflater().inflate(R.layout.adapter_view_layout,null);
TextView buyTextView = (TextView)convertView.findViewById(R.id.buyTextView);
TextView buyValueTextView = (TextView)convertView.findViewById(R.id.buyValueTextView);
TextView timeTextView = (TextView)convertView.findViewById(R.id.timeTextView);
return convertView;
}
}
}
how to parse json into base adapter custom list view ? Here is my code.Can anyone correctmy code?thank and appreciate .how to parse json into base adapter custom list view ? Here is my code.Can anyone correctmy code?thank and appreciate .how to parse json into base adapter custom list view ? Here is my code.Can anyone correctmy code?thank and appreciate .how to parse json into base adapter custom list view ? Here is my code.Can anyone correctmy code?thank and appreciate .how to parse json into base adapter custom list view ? Here is my code.Can anyone correctmy code?thank and appreciate .how to parse json into base adapter custom list view ? Here is my code.Can anyone correctmy code?thank and appreciate .how to parse json into base adapter custom list view ? Here is my code.Can anyone correctmy code?thank and appreciate .how to parse json into base adapter custom list view ? Here is my code.Can anyone correctmy code?thank and appreciate .how to parse json into base adapter custom list view ? Here is my code.Can anyone correctmy code?thank and appreciate .how to parse json into base adapter custom list view ? Here is my code.Can anyone correctmy code?thank and appreciate .how to parse json into base adapter custom list view ? Here is my code.Can anyone correctmy code?thank and appreciate .how to parse json into base adapter custom list view ? Here is my code.Can anyone correctmy code?thank and appreciate .how to parse json into base adapter custom list view ? Here is my code.Can anyone correctmy code?thank and appreciate .how to parse json into base adapter custom list view ? Here is my code.Can anyone correctmy code?thank and appreciate .how to parse json into base adapter custom list view ? Here is my code.Can anyone correctmy code?thank and appreciate .how to parse json into base adapter custom list view ? Here is my code.Can anyone correctmy code?thank and appreciate .how to parse json into base adapter custom list view ? Here is my code.Can anyone correctmy code?thank and appreciate .how to parse json into base adapter custom list view ? Here is my code.Can anyone correctmy code?thank and appreciate .how to parse json into base adapter custom list view ? Here is my code.Can anyone correctmy code?thank and appreciate .how to parse json into base adapter custom list view ? Here is my code.Can anyone correctmy code?thank and appreciate .how to parse json into base adapter custom list view ? Here is my code.Can anyone correctmy code?thank and appreciate .how to parse json into base adapter custom list view ? Here is my code.Can anyone correctmy code?thank and appreciate .
android
android
edited Nov 5 at 7:22
asked Nov 5 at 2:14
Sze Ko
11
11
You are initializing an ArrayAdapter, then using an uninitialized customAdapter.
– lionscribe
Nov 5 at 2:41
@lionscribe can you share the code?
– Sze Ko
Nov 5 at 2:51
You need to initialize listView also before access that
– Ashish Singhal
Nov 5 at 4:01
First get it working with static text, then worry about json.
– lionscribe
Nov 5 at 4:32
can someone correct my code?
– Sze Ko
Nov 5 at 4:45
|
show 1 more comment
You are initializing an ArrayAdapter, then using an uninitialized customAdapter.
– lionscribe
Nov 5 at 2:41
@lionscribe can you share the code?
– Sze Ko
Nov 5 at 2:51
You need to initialize listView also before access that
– Ashish Singhal
Nov 5 at 4:01
First get it working with static text, then worry about json.
– lionscribe
Nov 5 at 4:32
can someone correct my code?
– Sze Ko
Nov 5 at 4:45
You are initializing an ArrayAdapter, then using an uninitialized customAdapter.
– lionscribe
Nov 5 at 2:41
You are initializing an ArrayAdapter, then using an uninitialized customAdapter.
– lionscribe
Nov 5 at 2:41
@lionscribe can you share the code?
– Sze Ko
Nov 5 at 2:51
@lionscribe can you share the code?
– Sze Ko
Nov 5 at 2:51
You need to initialize listView also before access that
– Ashish Singhal
Nov 5 at 4:01
You need to initialize listView also before access that
– Ashish Singhal
Nov 5 at 4:01
First get it working with static text, then worry about json.
– lionscribe
Nov 5 at 4:32
First get it working with static text, then worry about json.
– lionscribe
Nov 5 at 4:32
can someone correct my code?
– Sze Ko
Nov 5 at 4:45
can someone correct my code?
– Sze Ko
Nov 5 at 4:45
|
show 1 more comment
1 Answer
1
active
oldest
votes
up vote
0
down vote
ArrayAdapter<String> mArrayAdapter = new ArrayAdapter<String>
(YourAdvertisement.this, android.R.layout.simple_expandable_list_item_1,
items);
listView.setAdapter(customAdapter);
Above place change the adapter class
Declare the CustomAdapter in Globle declaration
CustomAdapter cm;
cm = new CustomAdapter (this,items);
listView.setAdapter(cm);
@Override
public Object getItem(int position) {
return date.length();
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
convertView = getLayoutInflater().inflate(R.layout.adapter_view_layout,null);
TextView timeTextView = (TextView)convertView.findViewById(R.id.timeTextView);
timeTextView.setText(date[position]);
return convertView;
}
code is not working
– Sze Ko
Nov 5 at 7:15
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
ArrayAdapter<String> mArrayAdapter = new ArrayAdapter<String>
(YourAdvertisement.this, android.R.layout.simple_expandable_list_item_1,
items);
listView.setAdapter(customAdapter);
Above place change the adapter class
Declare the CustomAdapter in Globle declaration
CustomAdapter cm;
cm = new CustomAdapter (this,items);
listView.setAdapter(cm);
@Override
public Object getItem(int position) {
return date.length();
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
convertView = getLayoutInflater().inflate(R.layout.adapter_view_layout,null);
TextView timeTextView = (TextView)convertView.findViewById(R.id.timeTextView);
timeTextView.setText(date[position]);
return convertView;
}
code is not working
– Sze Ko
Nov 5 at 7:15
add a comment |
up vote
0
down vote
ArrayAdapter<String> mArrayAdapter = new ArrayAdapter<String>
(YourAdvertisement.this, android.R.layout.simple_expandable_list_item_1,
items);
listView.setAdapter(customAdapter);
Above place change the adapter class
Declare the CustomAdapter in Globle declaration
CustomAdapter cm;
cm = new CustomAdapter (this,items);
listView.setAdapter(cm);
@Override
public Object getItem(int position) {
return date.length();
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
convertView = getLayoutInflater().inflate(R.layout.adapter_view_layout,null);
TextView timeTextView = (TextView)convertView.findViewById(R.id.timeTextView);
timeTextView.setText(date[position]);
return convertView;
}
code is not working
– Sze Ko
Nov 5 at 7:15
add a comment |
up vote
0
down vote
up vote
0
down vote
ArrayAdapter<String> mArrayAdapter = new ArrayAdapter<String>
(YourAdvertisement.this, android.R.layout.simple_expandable_list_item_1,
items);
listView.setAdapter(customAdapter);
Above place change the adapter class
Declare the CustomAdapter in Globle declaration
CustomAdapter cm;
cm = new CustomAdapter (this,items);
listView.setAdapter(cm);
@Override
public Object getItem(int position) {
return date.length();
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
convertView = getLayoutInflater().inflate(R.layout.adapter_view_layout,null);
TextView timeTextView = (TextView)convertView.findViewById(R.id.timeTextView);
timeTextView.setText(date[position]);
return convertView;
}
ArrayAdapter<String> mArrayAdapter = new ArrayAdapter<String>
(YourAdvertisement.this, android.R.layout.simple_expandable_list_item_1,
items);
listView.setAdapter(customAdapter);
Above place change the adapter class
Declare the CustomAdapter in Globle declaration
CustomAdapter cm;
cm = new CustomAdapter (this,items);
listView.setAdapter(cm);
@Override
public Object getItem(int position) {
return date.length();
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
convertView = getLayoutInflater().inflate(R.layout.adapter_view_layout,null);
TextView timeTextView = (TextView)convertView.findViewById(R.id.timeTextView);
timeTextView.setText(date[position]);
return convertView;
}
answered Nov 5 at 6:19
suresh madaparthi
1439
1439
code is not working
– Sze Ko
Nov 5 at 7:15
add a comment |
code is not working
– Sze Ko
Nov 5 at 7:15
code is not working
– Sze Ko
Nov 5 at 7:15
code is not working
– Sze Ko
Nov 5 at 7:15
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53147461%2fparse-json-in-custom-list-view-base-adapter%23new-answer', 'question_page');
}
);
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
You are initializing an ArrayAdapter, then using an uninitialized customAdapter.
– lionscribe
Nov 5 at 2:41
@lionscribe can you share the code?
– Sze Ko
Nov 5 at 2:51
You need to initialize listView also before access that
– Ashish Singhal
Nov 5 at 4:01
First get it working with static text, then worry about json.
– lionscribe
Nov 5 at 4:32
can someone correct my code?
– Sze Ko
Nov 5 at 4:45