[Android] อยากแสดงข้อมูลตามประเภทอะค่ะ คือเมื่อคลิกปุ่มแต่ละปุ่มแล้วแสดงประเภทต่างๆกัน จากฐานข้อมูลน่ะค่ะ รบกวนช่วยด้วยค่ะ
ข้างล่างนี้เป็นหน้าจอที่ออกแบบไว้ค่ะ คือต้องการแสดงรายการสินค้า ซึ่งดึงมาจากฐานข้อมูล แต่ว่าแบ่งออกเป็นหมวดหมู่ด้วยค่ะ
จากภาพตรงที่เป็นรูปตรงข้างล่างค้นหาเป็น imageButton ค่ะ ถ้าอยากให้คลิกประเภทแล้วแสดงรายการสินค้าในประเภทนั้นๆ จะทำยังไงคะ และอยากให้มีค้นหาด้วยค่ะ รบกวนผู้รู้ช่วยชี้แนะแนวทางด้วยนะคะ
ตอนนี้ดิฉันให้แต่ละประเภทส่งค่า type เป็นตัวเลข 1-7 คือ ประเภทของมันค่ะ แต่ว่าพอคลิกแล้วมันไม่เกิดอะไรขึ้น ต้องไปเพิ่มโค้ดยังไงบ้างคะ แล้วก็อยากได้ตัวอย่างการค้นหาด้วยค่ะ ขอบคุณล่วงหน้าเลยนะคะ
Code (Java)
package com.BT.buytrash;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ListView;
import android.widget.TextView;
public class price extends Activity{
private EditText search;
private ImageButton type_iron;
private ImageButton type_plastic;
private ImageButton type_paper;
private ImageButton type_kew;
private ImageButton type_loha;
private ImageButton type_fifa;
private ImageButton type_other;
private ListView listview_product;
private ArrayList<String> data_listview_id = new ArrayList<String>();
private ArrayList<String> data_listview_name = new ArrayList<String>();
private ArrayList<String> data_listview_type = new ArrayList<String>();
private ArrayList<String> data_listview_price1 = new ArrayList<String>();
private ArrayList<String> data_listview_price2 = new ArrayList<String>();
private ArrayList<String> data_listview_price3 = new ArrayList<String>();
private ArrayList<String> data_listview_sale = new ArrayList<String>();
String url = "http://10.0.2.2/BuyTrash/price_product.php";
List<NameValuePair> params = new ArrayList<NameValuePair>();
//----------------------------------------------------------------
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.price);
search = (EditText) findViewById(R.id.EditText_search);
type_iron = (ImageButton) findViewById(R.id.Button_type_iron);
type_plastic = (ImageButton) findViewById(R.id.Button_type_plastic);
type_paper = (ImageButton) findViewById(R.id.Button_type_paper);
type_kew = (ImageButton) findViewById(R.id.Button_type_kew);
type_loha = (ImageButton) findViewById(R.id.Button_type_loha);
type_fifa = (ImageButton) findViewById(R.id.Button_type_fifa);
type_other = (ImageButton) findViewById(R.id.Button_type_other);
listview_product = (ListView) findViewById(R.id.listview_price);
params.add(new BasicNameValuePair("keyword", search.getText().toString()));
ArrayList<HashMap<String, String>> re = new ArrayList<HashMap<String, String>>(); ;
type_iron.setOnClickListener(new View.OnClickListener()
{
public void onClick(View v) {
params.add(new BasicNameValuePair("type", "1"));
}
});
type_plastic.setOnClickListener(new View.OnClickListener()
{
public void onClick(View v) {
params.add(new BasicNameValuePair("type", "2"));
}
});
type_paper.setOnClickListener(new View.OnClickListener()
{
public void onClick(View v) {
params.add(new BasicNameValuePair("type", "3"));
}
});
type_kew.setOnClickListener(new View.OnClickListener()
{
public void onClick(View v) {
params.add(new BasicNameValuePair("type", "5"));
}
});
type_loha.setOnClickListener(new View.OnClickListener()
{
public void onClick(View v) {
params.add(new BasicNameValuePair("type", "4"));
}
});
type_fifa.setOnClickListener(new View.OnClickListener()
{
public void onClick(View v) {
params.add(new BasicNameValuePair("type", "6"));
}
});
type_other.setOnClickListener(new View.OnClickListener()
{
public void onClick(View v) {
params.add(new BasicNameValuePair("type", "7"));
}
});
re = getHttpPost(url,params);
//------------------------------------------------------------
// Adapter
listview_product.setAdapter(new MyAdapters());
final AlertDialog.Builder viewDetail = new AlertDialog.Builder(this);
for(int i=0 ; i< re.size() ; i++)
{
data_listview_id.add(re.get(i).get("p_id").toString());
data_listview_name.add(re.get(i).get("p_name").toString());
data_listview_type.add(re.get(i).get("p_type").toString());
data_listview_price1.add(re.get(i).get("p_price1").toString());
data_listview_price2.add(re.get(i).get("p_price2").toString());
data_listview_price3.add(re.get(i).get("p_price3").toString());
data_listview_sale.add(re.get(i).get("p_sale").toString());
}
listview_product.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> adapter, View view, int position,long id)
{
viewDetail.setTitle(data_listview_name.get(position));
viewDetail.setMessage( " ปกติ : "+data_listview_price1.get(position)+
"\n ประจำ : "+data_listview_price2.get(position)+
"\n พิเศษ : "+data_listview_price3.get(position)+
"\n ขาย : "+data_listview_sale.get(position));
viewDetail.setPositiveButton("OK", new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int which)
{ dialog.dismiss(); }
});
viewDetail.show();
//Toast.makeText(getApplicationContext(), data_listview_name.get(position)+"\n ปกติ : "+ data_listview_price1.get(position)+"\n ประจำ : "+data_listview_price2.get(position)+"\n พิเศษ : "+data_listview_price3.get(position)+"\n ขาย : "+data_listview_sale.get(position), Toast.LENGTH_LONG).show();
}
});
}
//-------------------------------------------------------------------------------------
private class MyAdapters extends BaseAdapter{
private Holder holder;
public int getCount() {
return data_listview_id.size();
}
public Object getItem(int position) {
return null;
}
public long getItemId(int position) {
return 0;
}
public View getView(int position, View view, ViewGroup parent) {
if( view == null){
view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.list_price_item, null);
holder = new Holder();
holder.p_name = (TextView) view.findViewById(R.id.product_name);
view.setTag(holder);
}else{
holder = (Holder) view.getTag();
}
holder.p_name.setText(data_listview_name.get(position));
return view;
}
private class Holder{ //จะบอกว่า view แต่ละรายการมีอะไรบ้าง
public TextView p_name;
}
}
//----------------------------------------------------------------------------------------
public ArrayList<HashMap<String, String>> getHttpPost(String url, List<NameValuePair> params) {
// public ArrayList<String> getHttpPost(String url, List<NameValuePair> params) {
ArrayList<HashMap<String, String>> myArrList = new ArrayList<HashMap<String, String>>();
//String[][] re ;
InputStream is = null;
String result = "";
ArrayList<String> name = new ArrayList<String>();
// -------------------------------connect----------------------------------------------------
try {
HttpClient client = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(url);
// -------------------------------set UTF8 --------------------------------------------------
httpPost.setEntity(new UrlEncodedFormEntity(params,"UTF-8"));
HttpResponse response = client.execute(httpPost);
HttpEntity entity = response.getEntity();
is = entity.getContent();
}catch (Exception e) {
Log.e("log_tag", "Error in http connection " + e.toString());
}
// -------------------------------to String --------------------------------------------------
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(is, "iso-8859-11"), 8);
StringBuilder sb = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null) {
sb.append(line + "\n");
}
is.close();
result = sb.toString();
} catch (Exception e) {
Log.e("log_tag", "Error converting result " + e.toString());
}
// -------------------------------JSON to JAVA --------------------------------------------------
try {
JSONArray jArray = new JSONArray(result);
//re = new String[jArray.length()][7];
HashMap<String, String> map;
for (int i = 0; i < jArray.length(); i++) {
JSONObject json_data = jArray.getJSONObject(i);
map = new HashMap<String, String>();
map.put("p_id",json_data.getString("p_id") );
map.put("p_name", json_data.getString("p_name") );
map.put("p_type", json_data.getString("p_type") );
map.put("p_price1", json_data.getString("p_price1") );
map.put("p_price2", json_data.getString("p_price2") );
map.put("p_price3", json_data.getString("p_price3") );
map.put("p_sale", json_data.getString("p_sale") );
myArrList.add(map);
}
} catch (JSONException e) {
Log.e("log_tag", "Error parsing data " + e.toString());
}
return myArrList;
// return name;
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.login, menu);
return true;
}
}
Tag : Mobile, Android, JAVA
Date :
2012-11-23 23:40:35
By :
amiamika
View :
1372
Reply :
4
ตอนนี้สามารถแสดงตามประเภทได้แล้วค่ะ มีปัญหาคือ เวลาเข้าไปหน้านี้ ถ้าเรากดเลือกประเภทใดมันก็ขึ้นประเภทนั้น แต่พอเรากดอีกประเภทหนึ่ง ข้อมูลใน Listview มันค้างอะคะ มันไม่เปลี่ยนไปตามที่เรากด มันจะเป็นข้อมูลของประเภทแรกที่เรากดค่ะ ต้องแก้ไขตรงไหนคะ
Code (Java)
package com.BT.buytrash;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ListView;
import android.widget.TextView;
public class price extends Activity{
private EditText search;
private ImageButton type_iron;
private ImageButton type_plastic;
private ImageButton type_paper;
private ImageButton type_kew;
private ImageButton type_loha;
private ImageButton type_fifa;
private ImageButton type_other;
private ImageButton Button_search;
private ListView listview_product;
private ArrayList<String> data_listview_id = new ArrayList<String>();
private ArrayList<String> data_listview_name = new ArrayList<String>();
private ArrayList<String> data_listview_type = new ArrayList<String>();
private ArrayList<String> data_listview_price1 = new ArrayList<String>();
private ArrayList<String> data_listview_price2 = new ArrayList<String>();
private ArrayList<String> data_listview_price3 = new ArrayList<String>();
private ArrayList<String> data_listview_sale = new ArrayList<String>();
String url = "http://10.0.2.2/BuyTrash/price_product.php";
List<NameValuePair> params = new ArrayList<NameValuePair>();
//----------------------------------------------------------------
ArrayList<HashMap<String, String>> re = new ArrayList<HashMap<String, String>>();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.price);
search = (EditText) findViewById(R.id.EditText_search);
type_iron = (ImageButton) findViewById(R.id.Button_type_iron);
type_plastic = (ImageButton) findViewById(R.id.Button_type_plastic);
type_paper = (ImageButton) findViewById(R.id.Button_type_paper);
type_kew = (ImageButton) findViewById(R.id.Button_type_kew);
type_loha = (ImageButton) findViewById(R.id.Button_type_loha);
type_fifa = (ImageButton) findViewById(R.id.Button_type_fifa);
type_other = (ImageButton) findViewById(R.id.Button_type_other);
Button_search = (ImageButton) findViewById(R.id.button_search);
listview_product = (ListView) findViewById(R.id.listview_price);
final AlertDialog.Builder viewDetail = new AlertDialog.Builder(this);
params.add(new BasicNameValuePair("keyword", search.getText().toString()));
//re = getHttpPost(url,params);
type_iron.setOnClickListener(new View.OnClickListener()
{
public void onClick(View v) {
params.add(new BasicNameValuePair("type", "1"));
showList();
listview_product.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> adapter, View view, int position,long id)
{
viewDetail.setTitle(data_listview_name.get(position));
viewDetail.setMessage( " ปกติ : "+data_listview_price1.get(position)+
"\n ประจำ : "+data_listview_price2.get(position)+
"\n พิเศษ : "+data_listview_price3.get(position)+
"\n ขาย : "+data_listview_sale.get(position));
viewDetail.setPositiveButton("OK", new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int which)
{ dialog.dismiss(); }
});
viewDetail.show();
}
});
}
});
//-------------------------------------------------------------------------------------------
type_plastic.setOnClickListener(new View.OnClickListener()
{
public void onClick(View v) {
params.add(new BasicNameValuePair("type", "2"));
showList();
listview_product.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> adapter, View view, int position,long id)
{
viewDetail.setTitle(data_listview_name.get(position));
viewDetail.setMessage( " ปกติ : "+data_listview_price1.get(position)+
"\n ประจำ : "+data_listview_price2.get(position)+
"\n พิเศษ : "+data_listview_price3.get(position)+
"\n ขาย : "+data_listview_sale.get(position));
viewDetail.setPositiveButton("OK", new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int which)
{ dialog.dismiss(); }
});
viewDetail.show();
}
});
}
});
//-------------------------------------------------------------------------------------------
type_paper.setOnClickListener(new View.OnClickListener()
{
public void onClick(View v) {
params.add(new BasicNameValuePair("type", "3"));
showList();
listview_product.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> adapter, View view, int position,long id)
{
viewDetail.setTitle(data_listview_name.get(position));
viewDetail.setMessage( " ปกติ : "+data_listview_price1.get(position)+
"\n ประจำ : "+data_listview_price2.get(position)+
"\n พิเศษ : "+data_listview_price3.get(position)+
"\n ขาย : "+data_listview_sale.get(position));
viewDetail.setPositiveButton("OK", new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int which)
{ dialog.dismiss(); }
});
viewDetail.show();
}
});
}
});
//-------------------------------------------------------------------------------------------
type_kew.setOnClickListener(new View.OnClickListener()
{
public void onClick(View v) {
params.add(new BasicNameValuePair("type", "5"));
showList();
listview_product.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> adapter, View view, int position,long id)
{
viewDetail.setTitle(data_listview_name.get(position));
viewDetail.setMessage( " ปกติ : "+data_listview_price1.get(position)+
"\n ประจำ : "+data_listview_price2.get(position)+
"\n พิเศษ : "+data_listview_price3.get(position)+
"\n ขาย : "+data_listview_sale.get(position));
viewDetail.setPositiveButton("OK", new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int which)
{ dialog.dismiss(); }
});
viewDetail.show();
}
});
}
});
//-------------------------------------------------------------------------------------------
type_loha.setOnClickListener(new View.OnClickListener()
{
public void onClick(View v) {
params.add(new BasicNameValuePair("type", "4"));
showList();
listview_product.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> adapter, View view, int position,long id)
{
viewDetail.setTitle(data_listview_name.get(position));
viewDetail.setMessage( " ปกติ : "+data_listview_price1.get(position)+
"\n ประจำ : "+data_listview_price2.get(position)+
"\n พิเศษ : "+data_listview_price3.get(position)+
"\n ขาย : "+data_listview_sale.get(position));
viewDetail.setPositiveButton("OK", new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int which)
{ dialog.dismiss(); }
});
viewDetail.show();
}
});
}
});
//-------------------------------------------------------------------------------------------
type_fifa.setOnClickListener(new View.OnClickListener()
{
public void onClick(View v) {
params.add(new BasicNameValuePair("type", "6"));
showList();
listview_product.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> adapter, View view, int position,long id)
{
viewDetail.setTitle(data_listview_name.get(position));
viewDetail.setMessage( " ปกติ : "+data_listview_price1.get(position)+
"\n ประจำ : "+data_listview_price2.get(position)+
"\n พิเศษ : "+data_listview_price3.get(position)+
"\n ขาย : "+data_listview_sale.get(position));
viewDetail.setPositiveButton("OK", new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int which)
{ dialog.dismiss(); }
});
viewDetail.show();
}
});
}
});
//-------------------------------------------------------------------------------------------
type_other.setOnClickListener(new View.OnClickListener()
{
public void onClick(View v) {
params.add(new BasicNameValuePair("type", "7"));
showList();
listview_product.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> adapter, View view, int position,long id)
{
viewDetail.setTitle(data_listview_name.get(position));
viewDetail.setMessage( " ปกติ : "+data_listview_price1.get(position)+
"\n ประจำ : "+data_listview_price2.get(position)+
"\n พิเศษ : "+data_listview_price3.get(position)+
"\n ขาย : "+data_listview_sale.get(position));
viewDetail.setPositiveButton("OK", new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int which)
{ dialog.dismiss(); }
});
viewDetail.show();
}
});
}
});
//------------------------------------------------------------
// Adapter
/*
listview_product.setAdapter(new MyAdapters());
for(int i=0 ; i< re.size() ; i++)
{
data_listview_id.add(re.get(i).get("p_id").toString());
data_listview_name.add(re.get(i).get("p_name").toString());
data_listview_type.add(re.get(i).get("p_type").toString());
data_listview_price1.add(re.get(i).get("p_price1").toString());
data_listview_price2.add(re.get(i).get("p_price2").toString());
data_listview_price3.add(re.get(i).get("p_price3").toString());
data_listview_sale.add(re.get(i).get("p_sale").toString());
}
listview_product.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> adapter, View view, int position,long id)
{
viewDetail.setTitle(data_listview_name.get(position));
viewDetail.setMessage( " ปกติ : "+data_listview_price1.get(position)+
"\n ประจำ : "+data_listview_price2.get(position)+
"\n พิเศษ : "+data_listview_price3.get(position)+
"\n ขาย : "+data_listview_sale.get(position));
viewDetail.setPositiveButton("OK", new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int which)
{ dialog.dismiss(); }
});
viewDetail.show();
//Toast.makeText(getApplicationContext(), data_listview_name.get(position)+"\n ปกติ : "+ data_listview_price1.get(position)+"\n ประจำ : "+data_listview_price2.get(position)+"\n พิเศษ : "+data_listview_price3.get(position)+"\n ขาย : "+data_listview_sale.get(position), Toast.LENGTH_LONG).show();
}
});
*/
}
//-------------------------------------------------------------------------------------
private void showList(){
re = getHttpPost(url,params);
listview_product.setAdapter(new MyAdapters());
for(int i=0 ; i< re.size() ; i++)
{
data_listview_id.add(re.get(i).get("p_id").toString());
data_listview_name.add(re.get(i).get("p_name").toString());
data_listview_type.add(re.get(i).get("p_type").toString());
data_listview_price1.add(re.get(i).get("p_price1").toString());
data_listview_price2.add(re.get(i).get("p_price2").toString());
data_listview_price3.add(re.get(i).get("p_price3").toString());
data_listview_sale.add(re.get(i).get("p_sale").toString());
}
}
//-------------------------------------------------------------------------------------
private class MyAdapters extends BaseAdapter{
private Holder holder;
public int getCount() {
return data_listview_id.size();
}
public Object getItem(int position) {
return null;
}
public long getItemId(int position) {
return 0;
}
public View getView(int position, View view, ViewGroup parent) {
if( view == null){
view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.list_price_item, null);
holder = new Holder();
holder.p_name = (TextView) view.findViewById(R.id.product_name);
view.setTag(holder);
}else{
holder = (Holder) view.getTag();
}
holder.p_name.setText(data_listview_name.get(position));
return view;
}
private class Holder{ //จะบอกว่า view แต่ละรายการมีอะไรบ้าง
public TextView p_name;
}
}
//----------------------------------------------------------------------------------------
public ArrayList<HashMap<String, String>> getHttpPost(String url, List<NameValuePair> params) {
ArrayList<HashMap<String, String>> myArrList = new ArrayList<HashMap<String, String>>();
InputStream is = null;
String result = "";
ArrayList<String> name = new ArrayList<String>();
// -------------------------------connect----------------------------------------------------
try {
HttpClient client = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(url);
// -------------------------------set UTF8 --------------------------------------------------
httpPost.setEntity(new UrlEncodedFormEntity(params,"UTF-8"));
HttpResponse response = client.execute(httpPost);
HttpEntity entity = response.getEntity();
is = entity.getContent();
}catch (Exception e) {
Log.e("log_tag", "Error in http connection " + e.toString());
}
// -------------------------------to String --------------------------------------------------
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(is, "iso-8859-11"), 8);
StringBuilder sb = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null) {
sb.append(line + "\n");
}
is.close();
result = sb.toString();
} catch (Exception e) {
Log.e("log_tag", "Error converting result " + e.toString());
}
// -------------------------------JSON to JAVA --------------------------------------------------
try {
JSONArray jArray = new JSONArray(result);
//re = new String[jArray.length()][7];
HashMap<String, String> map;
for (int i = 0; i < jArray.length(); i++) {
JSONObject json_data = jArray.getJSONObject(i);
map = new HashMap<String, String>();
map.put("p_id",json_data.getString("p_id") );
map.put("p_name", json_data.getString("p_name") );
map.put("p_type", json_data.getString("p_type") );
map.put("p_price1", json_data.getString("p_price1") );
map.put("p_price2", json_data.getString("p_price2") );
map.put("p_price3", json_data.getString("p_price3") );
map.put("p_sale", json_data.getString("p_sale") );
myArrList.add(map);
}
} catch (JSONException e) {
Log.e("log_tag", "Error parsing data " + e.toString());
}
return myArrList;
// return name;
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.login, menu);
return true;
}
}
Date :
2012-11-24 23:17:15
By :
amiamika
Code เยอะขนาดนี้ผมไล่ดูไม่ไหวครับ
Date :
2012-11-25 20:39:30
By :
mr.win
ง่ะ แล้วพอมีตัวอย่างเกี่ยวกับการค้นหา แล้วแสดงเป็น ListView และ การแบ่งประเภทมั้ยคะ ขอบคุณค่ะ
Date :
2012-11-25 23:33:54
By :
amiamika
Load balance : Server 02