now i am using autocompleteTextview for showing suggestion , i get the data from webservice and and i set the adapter.
i dont get an error but when i click the Textview it wont show anything.and then I check the list and its contains the data.
am i doing a mistake here ?
here is my code
<AutoCompleteTextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/acCustomer"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/etCustomerOther"
android:layout_marginBottom="10dp"
android:layout_alignLeft="@+id/spCustomer"/>
--class--
private static List<String> customerList;
private class LoadCustomer extends AsyncTask<Void, Void, Void> {
@Override
protected void onPreExecute() {
getWindow().setFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE,
WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
pBar.setVisibility(View.VISIBLE);
pBar.setIndeterminate(false);
pBar.setClickable(false);
}
@Override
protected Void doInBackground(Void... params) {
try {
RESTClient client = new RESTClient(URLService+"get?method=getallcustomerlist&value=");
client.Execute(RESTClient.RequestMethod.GET);
responseCustomer = client.getResponse();
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(Void result) {
try{
responseCustomer = responseCustomer.replace("\\\"","\"");
responseCustomer = responseCustomer.substring(1, responseCustomer.length() - 1);
JSONParser jsonParser = new JSONParser();
JSONObject jsonObject = (JSONObject) jsonParser.parse(responseCustomer);
String Status = jsonObject.get("Status").toString();
if (Status == "true"){
// JSONArray structure = (JSONArray) jsonObject.get("DataList");
String dataku = jsonObject.get("DataList").toString();
try {
dataku = CRYYPT.decrypt(Enc_Pass, dataku);
}catch (GeneralSecurityException e){
//handle error - could be due to incorrect password or tampered encryptedMsg
}
JSONParser parser = new JSONParser();
JSONArray structure = (JSONArray) parser.parse(dataku);
customerList = new ArrayList<String>();
customerList.add("--Choose--");
for (int i = 0; i < structure.size(); i++) {
JSONObject customerlist = (JSONObject) structure.get(i);
customerList.add(customerlist.get("CustomerName").toString());
}
customerList.add("Other");
ArrayAdapter<String> adapter = new ArrayAdapter<String>(WorkflowActivity.this, android.R.layout.simple_list_item_1, customerList);
acCustomer.setAdapter(adapter);
}else {
}
}
catch(Exception e)
{
e.printStackTrace();
}
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
pBar.setClickable(true);
pBar.setVisibility(View.GONE);
}
}
--List Customer Item--
public class ListCustomerItem {
public String CustName;
/*public String CustLocation;
public String CustID;*/
}
--List Customer Adapter--
public class ListCustomerAdapter extends ArrayAdapter<ListCustomerItem> {
public ListCustomerAdapter(Context context, List<ListCustomerItem> items)
{
super(context, R.layout.style_fragment_list_customer, items);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder viewHolder;
if(convertView == null) {
// inflate the GridView item layout
LayoutInflater inflater = LayoutInflater.from(getContext());
convertView = inflater.inflate(R.layout.style_fragment_list_customer, parent, false);
// initialize the view holder
viewHolder = new ViewHolder();
viewHolder.tvCustName = (TextView) convertView.findViewById(R.id.tvCustName);
// viewHolder.tvCustLocation = (TextView) convertView.findViewById(R.id.tvCustLocation);
convertView.setTag(viewHolder);
} else {
// recycle the already inflated view
viewHolder = (ViewHolder) convertView.getTag();
}
// update the item view
ListCustomerItem item = getItem(position);
viewHolder.tvCustName.setText(item.CustName);
// viewHolder.tvCustLocation.setText(item.CustLocation);
return convertView;
}
private static class ViewHolder {
TextView tvCustName;
TextView tvCustLocation;
}
}