I am new in android and use Custom AutoCompleteTextView, here is code form AutoCompleteText
<com.xxxxxxxx.supports.CustomAutoComplete
android:id="#+id/edit_search"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#android:color/transparent"
android:completionThreshold="3"
android:ellipsize="end"
android:fontFamily="#font/roboto"
android:gravity="center_vertical"
android:hint="#string/search_products_colors_more"
android:imeActionId="123456"
android:imeOptions="actionSearch"
android:inputType="textCapWords"
android:paddingLeft="10dp"
android:textColor="#color/dark_text_color"
android:textColorHint="#color/light_text_color"
android:textSize="#dimen/font_14sp" />
This is list comes when I search some thing over server
and When I clicked on first item Steel Grey It shows like this.
I am not able to figure out the error, Sometime it comes and sometime not.
Please help.
Edit Update:
public class CustomAutoComplete extends android.support.v7.widget.AppCompatAutoCompleteTextView {
private static final int MESSAGE_TEXT_CHANGED = 100;
private static final int DEFAULT_AUTOCOMPLETE_DELAY = 750;
private int mAutoCompleteDelay = DEFAULT_AUTOCOMPLETE_DELAY;
private ProgressBar mLoadingIndicator;
#SuppressLint("HandlerLeak")
private final Handler mHandler = new Handler() {
#Override
public void handleMessage(Message msg) {
CustomAutoComplete.super.performFiltering((CharSequence) msg.obj, msg.arg1);
}
};
public CustomAutoComplete(Context context, AttributeSet attrs) {
super(context, attrs);
}
public void setLoadingIndicator(ProgressBar progressBar) {
mLoadingIndicator = progressBar;
}
public void setAutoCompleteDelay(int autoCompleteDelay) {
mAutoCompleteDelay = autoCompleteDelay;
}
#Override
protected void performFiltering(CharSequence text, int keyCode) {
if (mLoadingIndicator != null) {
mLoadingIndicator.setVisibility(View.VISIBLE);
}
mHandler.removeMessages(MESSAGE_TEXT_CHANGED);
mHandler.sendMessageDelayed(mHandler.obtainMessage(MESSAGE_TEXT_CHANGED, text), mAutoCompleteDelay);
}
#Override
public void onFilterComplete(int count) {
if (mLoadingIndicator != null) {
mLoadingIndicator.setVisibility(View.GONE);
}
super.onFilterComplete(count);
}
}
Model Class below here
public class SearchResults {
private String suggetions, suggetionId;
public SearchResults(String suggetions, String suggetionId) {
this.suggetions = suggetions;
this.suggetionId = suggetionId;
}
public String getSuggetions() {
return suggetions;
}
public String getSuggetionId() {
return suggetionId;
}
public void setSuggetionId(String suggetionId) {
this.suggetionId = suggetionId;
}}
Code in fragment class
public CustomAutoComplete edit_search;
edit_search.setThreshold(3);
edit_search.setAdapter(new SearchAdapter(getActivity(), resultList, SearchItems.this)); // 'this' is Activity instance
edit_search.setLoadingIndicator(progress_search);
edit_search.setOnEditorActionListener(new TextView.OnEditorActionListener() {
#Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
try {
getPerspective().closeKeyboard();
if (actionId == EditorInfo.IME_ACTION_SEARCH) {
if (resultList.size() != 0) {
if (edit_search.getText().length() > 2) {
String text = resultList.get(0).getSuggetions();
Log.e(TAG, "Text : " + text);
if (text.equalsIgnoreCase("No Results!")) {
edit_search.dismissDropDown();
layout_no_result.setVisibility(View.VISIBLE);
layout_mic.setVisibility(View.GONE);
} else {
layout_no_result.setVisibility(View.GONE);
layout_mic.setVisibility(View.VISIBLE);
getPerspective().openProdcuctList("0", text.trim());
}
} else if (edit_search.getText().length() < 3 && edit_search.getText().length() > 0) {
getPerspective().showMessage("Enter minimum three characters!");
} else if (edit_search.getText().length() <= 0) {
getPerspective().showMessage("Please enter your search query!");
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
});
edit_search.addTextChangedListener(new TextWatcher() {
#Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
#Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
if (edit_search.getText().length() == 0) {
layout_no_result.setVisibility(View.GONE);
layout_mic.setVisibility(View.VISIBLE);
}
}
#Override
public void afterTextChanged(Editable s) {
}
});
Now Adapter class code is
public class SearchAdapter extends BaseAdapter implements Filterable {
public Context context;
private List<SearchResults> resultsList;
SearchItems searchItems;
Perspective perspective;
private LayoutInflater inflater;
public Perspective getPerspective() {
if (perspective == null)
perspective = (Perspective) context;
return perspective;
}
public SearchAdapter(Context context, List<SearchResults> resultsList, SearchItems searchItems) {
this.context = context;
this.resultsList = resultsList;
this.searchItems = searchItems;
inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
#Override
public int getCount() {
return resultsList.size();
}
#Override
public Object getItem(int position) {
return resultsList.get(position);
}
#Override
public long getItemId(int position) {
return position;
}
#Override
public View getView(final int position, View convertView, ViewGroup parent) {
final ViewHolder viewHolder;
if (convertView == null) {
viewHolder = new ViewHolder();
convertView = inflater.inflate(R.layout.custom_search_result_row, parent, false);
viewHolder.txt_item_name = (TextView) convertView.findViewById(R.id.txt_item_name);
convertView.setTag(viewHolder);
} else {
viewHolder = (ViewHolder) convertView.getTag();
}
viewHolder.txt_item_name.setText(resultsList.get(position).getSuggetions());
viewHolder.txt_item_name.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
String query = resultsList.get(position).getSuggetions();
Log.e("Search","Query : "+query);
// searchItems.edit_search.setText(query);
if (!query.equals("No Results!")) {
getPerspective().closeKeyboard();
searchItems.edit_search.dismissDropDown();
getPerspective().openProdcuctList("0", query);
}
}
});
return convertView;
}
class ViewHolder {
TextView txt_item_name;
}
#Override
public Filter getFilter() {
return new Filter() {
#Override
protected FilterResults performFiltering(CharSequence constraint) {
FilterResults filterResults = new FilterResults();
if (constraint != null) {
List<SearchResults> listSuggs = findSuggastions(context, constraint.toString());
filterResults.values = listSuggs;
filterResults.count = listSuggs.size();
}
return filterResults;
}
#Override
protected void publishResults(CharSequence constraint, FilterResults results) {
if (results != null && results.count > 0) {
resultsList = (List<SearchResults>) results.values;
notifyDataSetChanged();
} else {
notifyDataSetInvalidated();
}
}
};
}
private List<SearchResults> findSuggastions(Context context, String title) {
resultsList.clear();
return resultsList = getSearchResults(title);
}
private List<SearchResults> getSearchResults(final String keyword) {
String tag_string_req = "req_top_search";
StringRequest strReq = new StringRequest(Request.Method.POST,
APIs.url_api_url, new Response.Listener<String>() {
#Override
public void onResponse(String response) {
try {
Log.e("SearchAdapter", "Response : " + response);
JSONArray object = new JSONArray(response);
//resultsList.clear();
for (int i = 0; i < object.length(); i++) {
JSONObject jsonObject = object.getJSONObject(i);
String prod_id = jsonObject.getString("product_id");
String prod_nam = jsonObject.getString("name");
SearchResults searchSuggs = new SearchResults(prod_nam, prod_id);
resultsList.add(searchSuggs);
}
if (resultsList.size() == 1) {
String prod_nam = resultsList.get(0).getSuggetions();
if (prod_nam.equalsIgnoreCase("No Results!")) {
searchItems.edit_search.dismissDropDown();
searchItems.layout_no_result.setVisibility(View.VISIBLE);
searchItems.layout_mic.setVisibility(View.GONE);
} else {
searchItems.layout_no_result.setVisibility(View.GONE);
searchItems.layout_mic.setVisibility(View.VISIBLE);
}
}else {
getPerspective().closeKeyboard();
}
notifyDataSetChanged();
} catch (Exception e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
}
}) {
#Override
protected Map<String, String> getParams() {
Map<String, String> params = new HashMap<>();
params.put("keyword", keyword);
return params;
}
};
strReq.setRetryPolicy(new RetryPolicy() {
#Override
public void retry(VolleyError arg0) throws VolleyError {
}
#Override
public int getCurrentTimeout() {
return 0;
}
#Override
public int getCurrentRetryCount() {
return 0;
}
});
strReq.setShouldCache(false);
Controller.getInstance().addToRequestQueue(strReq, tag_string_req);
return resultsList;
}
}
I have updated code,
Just Override toString methods and return data that you want to display.
public class SearchResults {
private String suggetions, suggetionId;
public SearchResults(String suggetions, String suggetionId) {
this.suggetions = suggetions;
this.suggetionId = suggetionId;
}
public String getSuggetions() {
return suggetions;
}
public String getSuggetionId() {
return suggetionId;
}
public void setSuggetionId(String suggetionId) {
this.suggetionId = suggetionId;
}
#Override
public final String toString()
{
return suggetions;
}
}
Related
I am using Epoxy Controller for Recycler View. I am having trouble changing the view after data changed by the user action.
Basically I have a switch button in a view which is used inside a recycler view and I am trying to update the view on switch button state change. I am calling requestModelBuild() in setProductList() function of the epoxy controller but change is not reflected in the view.
public class SellerInventoryListEpoxyController extends EpoxyController {
private List<Product> productList = Collections.emptyList();
private Context context;
private SellerInventoryListEpoxyController.Callbacks callbacks;
public void setProductList(List<Product> productList, Context context, SellerInventoryListEpoxyController.Callbacks callbacks) {
this.productList = productList;
this.context = context;
this.callbacks = callbacks;
requestModelBuild();
}
#Override
protected void buildModels() {
for (int i = 0; i < productList.size(); i++) {
new InventoryProductDetailModel_()
.id(productList.get(i).getId())
.product(productList.get(i))
.position(i)
.listSize(productList.size())
.callbacks(callbacks)
.context(context)
.addTo(this);
}
}
public interface Callbacks {
void onViewComboClick(Product productComboList);
void onProductListingStatusChanged(Boolean newStatus, int productSellerId);
void onRecyclerViewReachEnd();
}
}
public class InventoryProductDetailModel extends EpoxyModelWithHolder<InventoryProductDetailModel.ViewHolder> implements CompoundButton.OnCheckedChangeListener {
#EpoxyAttribute
Product product;
#EpoxyAttribute
int position;
#EpoxyAttribute
int listSize;
#EpoxyAttribute
Context context;
#EpoxyAttribute(EpoxyAttribute.Option.DoNotHash)
SellerInventoryListEpoxyController.Callbacks callbacks;
#Override
protected ViewHolder createNewHolder() {
return new ViewHolder();
}
#Override
protected int getDefaultLayout() {
return R.layout.inventroy_item_layout;
}
private DrawableCrossFadeFactory factory =
new DrawableCrossFadeFactory.Builder().setCrossFadeEnabled(true).build();
#Override
public void bind(#NonNull InventoryProductDetailModel.ViewHolder holder) {
super.bind(holder);
holder.quantity.setText(String.format("Available :%d", product.getTotalStock()));
holder.brand.setText(product.getProduct().getBrandName());
holder.title.setText(product.getProduct().getTitle());
holder.category.setText(product.getProduct().getCategoryName());
holder.sku.setText(String.format("Sku: %s", product.getSku()));
holder.inventoryItemConstrainLayout.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Intent intent = new Intent(context, ProductDetailActivity.class);
intent.putExtra("product_id", product.getId());
context.startActivity(intent);
}
});
if (product.getProductCombos() != null && product.getProductCombos().size() > 0) {
holder.variationCount.setVisibility(View.GONE);
holder.comboBtn.setVisibility(View.VISIBLE);
holder.comboBtn.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
callbacks.onViewComboClick(product);
}
});
}
if (product.getSellerActive()) {
holder.productStatusSwitch.setText("Active");
holder.productStatusSwitch.setOnCheckedChangeListener(null);
holder.productStatusSwitch.setChecked(true);
holder.productStatusSwitch.setOnCheckedChangeListener(this);
holder.productStatusSwitch.setTextColor(context.getResources().getColor(R.color.colorAccent));
} else {
holder.productStatusSwitch.setText("Inactive");
holder.productStatusSwitch.setOnCheckedChangeListener(null);
holder.productStatusSwitch.setChecked(false);
holder.productStatusSwitch.setOnCheckedChangeListener(this);
holder.productStatusSwitch.setTextColor(Color.parseColor("#ff0000"));
}
holder.variationCount.setText(format("Variation(%d)", product.getVariantCount()));
holder.variationCount.setVisibility(View.VISIBLE);
holder.comboBtn.setVisibility(View.GONE);
loadImage(holder.productImage, Utils.getRequiredUrlForThisImage(holder.productImage, product.getProduct().getImage()));
if (position == listSize - 2) {
callbacks.onRecyclerViewReachEnd();
}
}
#Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
callbacks.onProductListingStatusChanged(isChecked, product.getId());
}
private void loadImage(ImageView imageView, String url) {
Glide.with(imageView.getContext()).asBitmap()
.load(Utils.getRequiredUrlForThisImage(imageView, url))
.apply(new RequestOptions().diskCacheStrategy(DiskCacheStrategy.AUTOMATIC)
.fitCenter())
.transition(withCrossFade(factory))
.placeholder(R.mipmap.product)
.into(imageView);
}
#Override
public void unbind(#NonNull InventoryProductDetailModel.ViewHolder holder) {
super.unbind(holder);
}
public static class ViewHolder extends EpoxyHolder {
TextView quantity, brand, title, category, variationCount, comboBtn;
ImageView productImage, btn_product_detail;
ProgressBar progressBar;
ConstraintLayout inventoryItemConstrainLayout;
private TextView sku;
private Switch productStatusSwitch;
#Override
protected void bindView(#NonNull View itemView) {
productStatusSwitch = itemView.findViewById(R.id.productStatusSwitch);
quantity = itemView.findViewById(R.id.product_qty);
brand = itemView.findViewById(R.id.product_brand);
title = itemView.findViewById(R.id.product_title);
sku = itemView.findViewById(R.id.sku);
category = itemView.findViewById(R.id.product_category);
variationCount = itemView.findViewById(R.id.variantCount);
productImage = itemView.findViewById(R.id.product_image);
btn_product_detail = itemView.findViewById(R.id.btn_product_detail);
inventoryItemConstrainLayout = itemView.findViewById(R.id.inventory_item_constrain_layout);
comboBtn = itemView.findViewById(R.id.combo_btn);
progressBar = itemView.findViewById(R.id.progressbar);
progressBar.setVisibility(View.GONE);
}
}
#Override
public int hashCode() {
super.hashCode();
return product.hashCode();
}
#Override
public boolean equals(Object o) {
return super.equals(o);
}
}
private void addProductListingChangeObserver(final Boolean newStatus, final int productSellerId) {
ProductUpdate productUpdate = new ProductUpdate();
productUpdate.setSellerActive(newStatus);
mInventoryViewModel.updateProductSeller(productSellerId, productUpdate).observe(this, new Observer<Resource<ProductSeller>>() {
#Override
public void onChanged(Resource<ProductSeller> productSellerResource) {
if (productSellerResource.status == Status.ERROR) {
progressBar.setVisibility(View.GONE);
} else if (productSellerResource.status == Status.SUCCESS) {
progressBar.setVisibility(View.GONE);
if (productSellerResource.data != null && productSellerResource.data.isSellerActive() == newStatus) {
for (int i = 0; i < productList.size(); i++) {
if (productList.get(i).getId() == productSellerId) {
productList.get(i).setSellerActive(newStatus);
break;
}
}
sellerInventoryListEpoxyController.setProductList(productList, getContext(), InventoryFragment.this);
}
} else {
progressBar.setVisibility(View.VISIBLE);
}
}
});
}
In addProductListingChangeObserver() function one object of productList is modified and new productList is passed to the EpoxyController and requestModelbuild is called but the view is not modifying as expected.
I have difficulty making a listview search on Android, please help me.
this is my getter setter, the name is toko.java
public class Toko {
private String no;
private String str_id;
private String nama;
private String alamat;
private String kabupaten;
private String provinsi;
private String latitude;
private String longitude;
private String sms;
public void setNo(String no) {
this.no = no;
}
String getNo() {
return no;
}
public void setStr_id (String str_id) {
this.str_id = str_id;
}
String getStr_id() {
return str_id;
}
public void setNama (String nama) {
this.nama = nama;
}
public String getNama() {
return nama;
}
public void setAlamat (String alamat) {
this.alamat = alamat;
}
String getAlamat() {
return alamat;
}
public void setKabupaten (String kabupaten) {
this.kabupaten = kabupaten;
}
String getKabupaten() {
return kabupaten;
}
public void setProvinsi (String provinsi) {
this.provinsi = provinsi;
}
String getProvinsi() {
return provinsi;
}
public void setLatitude (String latitude) {
this.latitude = latitude;
}
String getLatitude() {
return latitude;
}
public void setLongitude (String longitude) {
this.longitude = longitude;
}
String getLongitude() {
return longitude;
}
public void setSms (String sms) {
this.sms = sms;
}
String getSms() {
return sms;
}
}
this is my adapter, the name is TokoAdapter.java
public class TokoAdapter extends BaseAdapter implements Filterable {
//private ArrayList<HashMap<String, String>> data;
private ArrayList<Toko> data_toko = new ArrayList<Toko>();
private List<String> originalData = null;
private List<String> filteredData = null;
private ItemFilter mFilter = new ItemFilter();
private static LayoutInflater inflater = null;
public TokoAdapter(Activity a, ArrayList<Toko> d) {
data_toko = d;
inflater = (LayoutInflater) a.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
public int getCount() {
return data_toko.size();
}
public Object getItem(int position) {
return data_toko.get(position);
}
public long getItemId(int position) {
return position;
}
#SuppressLint("InflateParams")
#Override
public View getView(int position, View convertView, ViewGroup parent) {
View vi = convertView;
if (convertView == null) {
vi = inflater.inflate(R.layout.listview_toko, null);
}
TextView no = vi.findViewById(R.id.no);
TextView str_id = vi.findViewById(R.id.str_id);
TextView nama = vi.findViewById(R.id.nama);
TextView alamat = vi.findViewById(R.id.alamat);
TextView kabupaten = vi.findViewById(R.id.kabupaten);
TextView provinsi = vi.findViewById(R.id.provinsi);
TextView latitude = vi.findViewById(R.id.latitude);
TextView longitude = vi.findViewById(R.id.longitude);
TextView sms = vi.findViewById(R.id.sms);
Toko daftar_toko = data_toko.get(position);
no.setText(daftar_toko.getNo());
str_id.setText(daftar_toko.getStr_id());
nama.setText(daftar_toko.getNama());
alamat.setText(daftar_toko.getAlamat());
kabupaten.setText(daftar_toko.getKabupaten());
provinsi.setText(daftar_toko.getProvinsi());
latitude.setText(daftar_toko.getLatitude());
longitude.setText(daftar_toko.getLongitude());
sms.setText(daftar_toko.getSms());
return vi;
}
#Override
public Filter getFilter() {
return mFilter;
}
private class ItemFilter extends Filter {
#Override
protected FilterResults performFiltering(CharSequence constraint) {
String filterString = constraint.toString().toLowerCase();
FilterResults results = new FilterResults();
final List<String> list = originalData;
int count = list.size();
final ArrayList<String> nlist = new ArrayList<>(count);
String filterableString;
for (int i = 0; i < count; i++) {
filterableString = list.get(i);
if (filterableString.toLowerCase().contains(filterString)) {
nlist.add(filterableString);
}
}
results.values = nlist;
results.count = nlist.size();
return results;
}
#SuppressWarnings("unchecked")
#Override
protected void publishResults(CharSequence constraint, FilterResults results) {
filteredData = (ArrayList<String>) results.values;
notifyDataSetChanged();
}
}
}
this is my layout code, the name is activity_read_toko.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".crud.toko.ReadTokoActivity"
android:padding="10dp"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<EditText
android:id="#+id/key"
android:layout_width="347dp"
android:layout_height="match_parent"
android:background="#drawable/search_view"
android:hint="#string/pencarian_nama_toko"
android:inputType="text"
android:padding="10dp" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:src="#drawable/ic_search_black_24dp"
android:id="#+id/toko_btnSearch"
android:padding="10dp"/>
</LinearLayout>
<ListView
android:id="#+id/listview_toko"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="10dp" />
</LinearLayout>
and this is my activity code, the name is ReadTokoActivity.java
public class ReadTokoActivity extends AppCompatActivity implements View.OnClickListener, TextWatcher {
ListView list;
JSONParser jParser = new JSONParser();
ArrayList<Toko> daftar_toko = new ArrayList<Toko>();
JSONArray daftarToko, daftarSearchToko = null;
ImageButton BtnSearch;
TokoAdapter adapter;
EditText Query;
String query, url;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_read_toko);
list = (ListView) findViewById(R.id.listview_toko);
BtnSearch = findViewById(R.id.toko_btnSearch);
Query = findViewById(R.id.key);
// BtnSearch.setOnClickListener(this);
Query.addTextChangedListener(this);
//jalankan ReadDataTask
ReadDataTask m= (ReadDataTask) new ReadDataTask().execute();
}
#SuppressLint("StaticFieldLeak")
class ReadDataTask extends AsyncTask<String, String, String> {
ProgressDialog pDialog;
#Override
protected void onPreExecute() {
super.onPreExecute();
pDialog = new ProgressDialog(ReadTokoActivity.this);
pDialog.setMessage("Mohon Tunggu..");
pDialog.setIndeterminate(true);
pDialog.setCancelable(true);
pDialog.show();
}
#Override
protected String doInBackground(String... sText) {
return getDataList();
}
#Override
protected void onPostExecute(String result) {
super.onPostExecute(result);
pDialog.dismiss();
if(result.equalsIgnoreCase("Exception Caught")){
Toast.makeText(ReadTokoActivity.this, "Unable to connect to server,please check your internet connection!", Toast.LENGTH_LONG).show();
}
if(result.equalsIgnoreCase("no results")){
Toast.makeText(ReadTokoActivity.this, "Data empty", Toast.LENGTH_LONG).show();
}else {
adapter = new TokoAdapter(ReadTokoActivity.this,daftar_toko);
list.setAdapter(adapter);
//Adapter menampilkan data mahasiswa ke dalam listView
}
}
//method untuk memperoleh daftar mahasiswa dari JSON
String getDataList(){
Toko tempMarker = new Toko();
List<NameValuePair> parameter = new ArrayList<NameValuePair>();
try {
JSONObject json = jParser.makeHttpRequest(Konfigurasi.URL_READ_TOKO,"POST", parameter);
int success = json.getInt(Konfigurasi.TAG_SUCCESS);
if (success == 1) { //Ada record Data (SUCCESS = 1)
//Getting Array of daftar_mhs
daftarToko = json.getJSONArray(Konfigurasi.TAG_TOKO);
// looping through All daftar_mhs
for (int i = 0; i < daftarToko.length(); i++){
JSONObject c = daftarToko.getJSONObject(i);
tempMarker = new Toko();
tempMarker.setNo(c.getString(Konfigurasi.TAG_NO));
tempMarker.setStr_id(c.getString(Konfigurasi.TAG_STR_ID));
tempMarker.setNama(c.getString(Konfigurasi.TAG_NAMA));
tempMarker.setAlamat(c.getString(Konfigurasi.TAG_ALAMAT));
tempMarker.setKabupaten(c.getString(Konfigurasi.TAG_KABUPATEN));
tempMarker.setProvinsi(c.getString(Konfigurasi.TAG_PROVINSI));
tempMarker.setLatitude(c.getString(Konfigurasi.TAG_LATITUDE));
tempMarker.setLongitude(c.getString(Konfigurasi.TAG_LONGITUDE));
tempMarker.setSms(c.getString(Konfigurasi.TAG_SMS));
daftar_toko.add(tempMarker);
}
return "OK";
}else{
//Tidak Ada Record Data (SUCCESS = 0)
return "no results";
}
} catch (Exception e) {
e.printStackTrace();
return "Exception Caught";
}
}
}
#Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
#Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
#Override
public void afterTextChanged(Editable s) {
String text = Query.getText().toString().toLowerCase(Locale.getDefault());
adapter.getFilter().filter(text);
}
#Override
public void onClick(View v) {
}
}
and when I enter keywords in edittext, there is no change in listview.
please solve my problem.
and I search my problem in google, and none of them succeeded.
While you get your string in after TextChanged
#Override
public void afterTextChanged(Editable s) {
String names = s.toString();
List<Toko> newList = new ArrayList<>();
for (Toko r : cityList){
//citylist will be your daftar_toko list
String name = r.getCity();
if (name.toLowerCase().contains(names.toLowerCase())){
newList.add(r);
}
}
//make seFilter method in adapter and pass your new list
mAdapter.setFilter(newList);
}
Making method in Adapter
public void setFilter(List<Toko> newList){
data_toko = new ArrayList<>();
data_toko.addAll(newList);
notifyDataSetChanged();
}
Try This
msearch.addTextChangedListener(new TextWatcher() {
#Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
#Override
public void onTextChanged(CharSequence s, int start, int before, int count){
int textlength = s.length();
ArrayList<SqliteGetSet> tempArrayList = new ArrayList<SqliteGetSet>();
for(SqliteGetSet c: list){
if (textlength <= c.getName().length()) {
if (c.getName().toLowerCase().contains(s.toString().toLowerCase())
|| c.getMno().toLowerCase().contains(s.toString().toLowerCase()))
{
tempArrayList.add(c);
}
}
}
adapter = new SqliteAdapter(SqliteExample.this,R.layout.row_sqlite_list, tempArrayList);
listView.setAdapter(adapter);
}
#Override
public void afterTextChanged(Editable s) {
}
});
msearch - Edittext name
SqliteGetSet - Model Class
I'm not able to see the recycle view, not sure where It has gone wrong. It would be great if you can help me.
Fragment
public class CallDurationFragment extends Fragment {
final FirebaseDatabase database = FirebaseDatabase.getInstance();
ArrayList<CallHistroy> callList = new ArrayList<>();
ArrayList<CallHistroy> callListTemp = new ArrayList<>();
ArrayList<CallHistroy> callObject = new ArrayList<>();
ArrayList<CallHistroy> callListText = new ArrayList<>();
private CallDurationFragment.OnFragmentInteractionListener mListener;
private RecyclerView rvCall;
private RecyclerView.Adapter callAdaptor;
private RecyclerView.LayoutManager eLayoutManager;
private EditText phoneNumber;
private static final int DIALOG_DATE_PICKER = 100;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_callduration_list, container, false);
phoneNumber = (EditText) getActivity().findViewById(editTextSearchKeyPhoneNo);
Context context = getActivity();
rvCall = (RecyclerView) rootView.findViewById(R.id.rvCallDuration);
rvCall.setHasFixedSize(true);
rvCall.setLayoutManager(eLayoutManager);
eLayoutManager = new LinearLayoutManager(getActivity());
phoneNumber.addTextChangedListener(new TextWatcher() {
public void afterTextChanged(Editable s) {
callListTemp = getAllCallRecords();
for(int i = 0 ; i < callListTemp.size() ; i++)
if(callListTemp.get(i).getPhoneNumber().contains(s.toString()) )
callListText.add(callListTemp.get(i));
callList = calculateIncomingOutgoing();
callAdaptor = new CallDurationAdapter(getActivity(), callList);
rvCall.setAdapter(callAdaptor);
}
public void beforeTextChanged(CharSequence s, int start,
int count, int after) {
}
public void onTextChanged(CharSequence s, int start,
int before, int count) {
}
});
callList = calculateIncomingOutgoing();
callAdaptor = new CallDurationAdapter(getActivity(), callList);
rvCall.setAdapter(callAdaptor);
return rootView;
}
public ArrayList<CallHistroy> getAllCallRecords(){
DatabaseReference ref = database.getReference();
ref.child("Call").addValueEventListener(new ValueEventListener() {
#Override
public void onDataChange(DataSnapshot dataSnapshot) {
callObject.clear();
HashMap<String,Object> call = null;
Iterator<DataSnapshot> items = dataSnapshot.getChildren().iterator();
while(items.hasNext()){
DataSnapshot item = items.next();
Log.e("Listener",item.toString() );
call =(HashMap<String, Object>) item.getValue();
callObject.add(new CallHistroy(call.get("phoneNumber").toString(),call.get("mode").toString(),call.get("duration").toString(), call.get("date").toString(),item.getKey()));
}
}
#Override
public void onCancelled(DatabaseError databaseError) {
}
});
return callObject;
}
public ArrayList<CallHistroy> calculateIncomingOutgoing(){
if(callListText.size() > 0){
callList = callListText;
}else {
callList = getAllCallRecords();
}
ArrayList<CallHistroy> callHistroyIncomingOutgoing = new ArrayList<>();
if(callList.size() > 0){
if(callList.get(0).getMode().equals("Outgoing")) {
callHistroyIncomingOutgoing.add(new CallHistroy(callList.get(0).getPhoneNumber(), "0", callList.get(0).getDuration()));
}else{
callHistroyIncomingOutgoing.add(new CallHistroy(callList.get(0).getPhoneNumber(), callList.get(0).getDuration(), "0"));
}
}
for( int i = 1 ; i < callList.size() ; i++){
boolean setValue = false;
for (int j = 0; j < callHistroyIncomingOutgoing.size() ;j++){
if( callHistroyIncomingOutgoing.get(j).getPhoneNumber().equals(callList.get(i).getPhoneNumber())){
setValue = true;
int incoming = Integer.parseInt(callHistroyIncomingOutgoing.get(j).getIncomingDuration());
int outgoing = Integer.parseInt( callHistroyIncomingOutgoing.get(j).getOutgoingDuration());
int duration = Integer.parseInt( callList.get(i).getDuration());
if(callList.get(i).getMode().equals("Outgoing")) {
callHistroyIncomingOutgoing.get(j).updateDuration(String.valueOf(incoming), String.valueOf(outgoing + duration));
}else{
callHistroyIncomingOutgoing.get(j).updateDuration(String.valueOf(incoming + duration), String.valueOf(outgoing));
}
}
}
if(!setValue) {
if(callList.get(i).getMode() == "Outgoing") {
callHistroyIncomingOutgoing.add(new CallHistroy(callList.get(i).getPhoneNumber(), "0", callList.get(i).getDuration()));
}else{
callHistroyIncomingOutgoing.add(new CallHistroy(callList.get(i).getPhoneNumber(), callList.get(i).getDuration(), "0"));
}
}
}
return callHistroyIncomingOutgoing;
}
#Override
public void onAttach(Context context) {
super.onAttach(context);
if (context instanceof CallListFragment.OnFragmentInteractionListener) {
mListener = (CallDurationFragment.OnFragmentInteractionListener) context;
}
}
#Override
public void onDetach() {
super.onDetach();
mListener = null;
}
#Override
public void onPause(){
super.onPause();
}
#Override
public void onDestroyView(){
super.onDestroyView();
}
#Override
public void onDestroy(){
super.onDestroy();
}
public interface OnFragmentInteractionListener {
// TODO: Update argument type and name
void onFragmentInteraction(Uri uri);
}
}
Adaptor
RecyclerView.Adapter<CallDurationAdapter.ViewHolder> {
private List<CallHistroy> mCalls;
private Context mContext;
public CallDurationAdapter(Context context, List<CallHistroy> calls) {
mCalls = calls;
mContext = context;
}
private Context getContext() {
return mContext;
}
#Override
public CallDurationAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
Context context = parent.getContext();
LayoutInflater inflater = LayoutInflater.from(context);
// Inflate the custom layout
View callDurationView = inflater.inflate(R.layout.item_call_duration_details, parent, false);
// Return a new holder instance
ViewHolder viewHolder = new ViewHolder(callDurationView);
return viewHolder;
}
#Override
public void onBindViewHolder(CallDurationAdapter.ViewHolder viewHolder, final int position) {
// Get the data model based on position
final CallHistroy ch = mCalls.get(position);
// Set item views based on your views and data model
viewHolder._phoneNoTextView.setText(ch.getPhoneNumber());
viewHolder._incomingTextView.setText(ch.getIncomingDuration());
viewHolder._outgoingTextView.setText(ch.getOutgoingDuration());
final String key = ch.getKey();
}
#Override
public int getItemCount() {
return mCalls.size();
}
public class ViewHolder extends RecyclerView.ViewHolder {
public TextView _phoneNoTextView;
public TextView _incomingTextView;
public TextView _outgoingTextView;
public ViewHolder(View itemView) {
super(itemView);
_phoneNoTextView = (TextView) itemView.findViewById(R.id.rvs_duration_phone_no);
_incomingTextView = (TextView) itemView.findViewById(R.id.rvs_duration_outing_total_call);
_outgoingTextView = (TextView) itemView.findViewById(R.id.rvs_duration_incoming_total_call);
}
}
}
Activity
public class CallDurationActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_call_duration);
CallDurationFragment newFragment = new CallDurationFragment();
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
transaction.replace(R.id.recordFragmentContainer, newFragment);
transaction.addToBackStack(null);
transaction.commit();
}
public void refreshCallDuration(View v) {
Intent intent = new Intent(this, CallDurationActivity.class);
startActivity(intent);
}
protected void onPause() {
super.onPause();
}
protected void onStop() {
super.onStop();
}
protected void onDestroy() {
super.onDestroy();
}
public void onBackCallDuration(View v) {
if (getFragmentManager().getBackStackEntryCount() > 0) {
getFragmentManager().popBackStack();
} else {
super.onBackPressed();
}
}
}
Object
public class CallHistroy implements Comparable<CallHistroy> {
String phoneNumber;
String mode;
String duration;
String date;
String key;
String incomingDuration;
String outgoingDuration;
int totalIncoming;
int totalOutgoing;
public CallHistroy(String _phontNumber, String _incomingDuration, String _outgoingDuration ){
setPhoneNumber( _phontNumber );
setIncomingDuration( _incomingDuration );
setOutgoingDuration( _outgoingDuration );
}
public CallHistroy(String _date, int _totalIncoming, int _totalOutgoing ){
setDate(_date);
setTotalIncoming( _totalIncoming );
setTotalOutgoing( _totalOutgoing );
}
public void updateCall(int _totalIncoming, int _totalOutgoing){
setTotalIncoming( _totalIncoming );
setTotalOutgoing( _totalOutgoing );
}
public void updateDuration(String _incomingDuration, String _outgoingDuration){
setOutgoingDuration( _incomingDuration );
setIncomingDuration( _outgoingDuration );
}
public CallHistroy(String _phoneNumber, String _mode, String _duration, String _date ){
setPhoneNumber( _phoneNumber );
setDuration( _duration );
setDate( _date );
setMode( _mode );
}
public CallHistroy(String _phoneNumber, String _mode, String _duration, String _date, String _key ){
setPhoneNumber( _phoneNumber );
setDuration( _duration );
setDate( _date );
setMode( _mode );
setKey( _key );
}
public String getIncomingDuration() {
return incomingDuration;
}
public String getOutgoingDuration() {
return outgoingDuration;
}
public int getTotalIncoming() {
return totalIncoming;
}
public int getTotalOutgoing() {
return totalOutgoing;
}
public void setIncomingDuration(String incomingDuration) {
this.incomingDuration = incomingDuration;
}
public void setOutgoingDuration(String outgoingDuration) {
this.outgoingDuration = outgoingDuration;
}
public void setTotalIncoming(int totalIncoming) {
this.totalIncoming = totalIncoming;
}
public void setTotalOutgoing(int totalOutgoing) {
this.totalOutgoing = totalOutgoing;
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public String getPhoneNumber() {
return phoneNumber;
}
public String getDate() {
return date;
}
public String getMode() {
return mode;
}
public String getDuration() {
return duration;
}
public void setPhoneNumber(String phoneNumber) {
this.phoneNumber = phoneNumber;
}
public void setDate(String date) {
this.date = date;
}
public void setDuration(String duration) {
this.duration = duration;
}
public void setMode(String mode) {
this.mode = mode;
}
#Override
public int compareTo(#NonNull CallHistroy callHistroyObject) {
String[] part = callHistroyObject.date.split("/");
String[] part1 = date.split("/");
int date = Integer.parseInt(part[0]);
int month = Integer.parseInt(part[1]);
String _year = part[2];
int year = Integer.parseInt(_year.substring(0,4));
int date1 = Integer.parseInt(part1[0]);
int month1 = Integer.parseInt(part1[1]);
String _year1 = part1[2];
int year1 = Integer.parseInt(_year1.substring(0,4));
if(year > year1)
return -1;
else if(month > month1)
return -1;
else if(date >date1)
return -1;
else
return 0;
}
}
You're setting your layout manager before it's created
rvCall.setLayoutManager(eLayoutManager);
eLayoutManager = new LinearLayoutManager(getActivity());
should be
eLayoutManager = new LinearLayoutManager(getActivity());
rvCall.setLayoutManager(eLayoutManager);
I want to use this from the material-dialog library without using the library in my build.gradle file.
Is there a way to do that?
Thanks to Abderrahim Soubai Elidrissi deleted answer I used LovelyDialog and implemented the following classes in my project:
AbsLovelyDialog.java
#SuppressWarnings({"unchecked", "WeakerAccess"})
public abstract class AbsLovelyDialog<T extends AbsLovelyDialog> {
private static final String KEY_SAVED_STATE_TOKEN = "key_saved_state_token";
private Dialog dialog;
private View dialogView;
private ImageView iconView;
private TextView topTitleView;
private TextView titleView;
private TextView messageView;
public AbsLovelyDialog(Context context) {
init(new AlertDialog.Builder(context));
}
public AbsLovelyDialog(Context context, int theme) {
init(new AlertDialog.Builder(context, theme));
}
private void init(AlertDialog.Builder dialogBuilder) {
dialogView = LayoutInflater.from(dialogBuilder.getContext()).inflate(getLayout(), null);
dialog = dialogBuilder.setView(dialogView).create();
iconView = findView(R.id.ld_icon);
titleView = findView(R.id.ld_title);
messageView = findView(R.id.ld_message);
topTitleView = findView(R.id.ld_top_title);
}
#LayoutRes
protected abstract int getLayout();
public T setMessage(#StringRes int message) {
return setMessage(string(message));
}
public T setMessage(CharSequence message) {
messageView.setVisibility(View.VISIBLE);
messageView.setText(message);
return (T) this;
}
public T setTitle(#StringRes int title) {
return setTitle(string(title));
}
public T setTopTitle(#StringRes int title) {
return setTopTitle(string(title));
}
public T setTitle(CharSequence title) {
titleView.setVisibility(View.VISIBLE);
titleView.setText(title);
return (T) this;
}
public T setTopTitle(CharSequence title) {
topTitleView.setVisibility(View.VISIBLE);
topTitleView.setText(title);
return (T) this;
}
public T setTopTitleColor(int color) {
topTitleView.setTextColor(color);
return (T) this;
}
public T setIcon(Bitmap bitmap) {
iconView.setVisibility(View.VISIBLE);
iconView.setImageBitmap(bitmap);
return (T) this;
}
public T setIcon(Drawable drawable) {
iconView.setVisibility(View.VISIBLE);
iconView.setImageDrawable(drawable);
return (T) this;
}
public T setIcon(#DrawableRes int iconRes) {
iconView.setVisibility(View.VISIBLE);
iconView.setImageResource(iconRes);
return (T) this;
}
public T setIconTintColor(int iconTintColor) {
iconView.setColorFilter(iconTintColor);
return (T) this;
}
public T setTitleGravity(int gravity) {
titleView.setGravity(gravity);
return (T) this;
}
public T setMessageGravity(int gravity) {
messageView.setGravity(gravity);
return (T) this;
}
public T setTopColor(#ColorInt int topColor) {
findView(R.id.ld_color_area).setBackgroundColor(topColor);
return (T) this;
}
public T setTopColorRes(#ColorRes int topColoRes) {
return setTopColor(color(topColoRes));
}
/*
* You should call method saveInstanceState on handler object and then use saved info to restore
* your dialog in onRestoreInstanceState. Static methods wasDialogOnScreen and getDialogId will
* help you in this.
*/
public T setInstanceStateHandler(int id, LovelySaveStateHandler handler) {
handler.handleDialogStateSave(id, this);
return (T) this;
}
public T setCancelable(boolean cancelable) {
dialog.setCancelable(cancelable);
return (T) this;
}
public T setSavedInstanceState(Bundle savedInstanceState) {
if (savedInstanceState != null) {
boolean hasSavedStateHere =
savedInstanceState.keySet().contains(KEY_SAVED_STATE_TOKEN) &&
savedInstanceState.getSerializable(KEY_SAVED_STATE_TOKEN) == getClass();
if (hasSavedStateHere) {
restoreState(savedInstanceState);
}
}
return (T) this;
}
public Dialog show() {
dialog.show();
return dialog;
}
public Dialog create() {
return dialog;
}
public void dismiss() {
dialog.dismiss();
}
void onSaveInstanceState(Bundle outState) {
outState.putSerializable(KEY_SAVED_STATE_TOKEN, getClass());
}
void restoreState(Bundle savedState) {
}
boolean isShowing() {
return dialog != null && dialog.isShowing();
}
protected String string(#StringRes int res) {
return dialogView.getContext().getString(res);
}
protected int color(#ColorRes int colorRes) {
return ContextCompat.getColor(getContext(), colorRes);
}
protected Context getContext() {
return dialogView.getContext();
}
protected <ViewClass extends View> ViewClass findView(int id) {
return (ViewClass) dialogView.findViewById(id);
}
protected class ClickListenerDecorator implements View.OnClickListener {
private View.OnClickListener clickListener;
private boolean closeOnClick;
protected ClickListenerDecorator(View.OnClickListener clickListener, boolean closeOnClick) {
this.clickListener = clickListener;
this.closeOnClick = closeOnClick;
}
#Override
public void onClick(View v) {
if (clickListener != null) {
if (clickListener instanceof LovelyDialogCompat.DialogOnClickListenerAdapter) {
LovelyDialogCompat.DialogOnClickListenerAdapter listener =
(LovelyDialogCompat.DialogOnClickListenerAdapter) clickListener;
listener.onClick(dialog, v.getId());
} else {
clickListener.onClick(v);
}
}
if (closeOnClick) {
dismiss();
}
}
}
}
LovelyChoiceDialog.java
public class LovelyChoiceDialog extends AbsLovelyDialog<LovelyChoiceDialog> {
private static final String KEY_ITEM_CHECKED_STATES = "key_item_checked_states";
private ListView choicesList;
private TextView confirmButton;
{
choicesList = findView(R.id.ld_choices);
}
public LovelyChoiceDialog(Context context) {
super(context);
}
public LovelyChoiceDialog(Context context, int theme) {
super(context, theme);
}
public <T> LovelyChoiceDialog setItems(T[] items, OnItemSelectedListener<T> itemSelectedListener) {
return setItems(Arrays.asList(items), itemSelectedListener);
}
public <T> LovelyChoiceDialog setItems(List<T> items, OnItemSelectedListener<T> itemSelectedListener) {
ArrayAdapter<T> adapter = new ArrayAdapter<>(getContext(),
R.layout.dialog_item_simple_text, android.R.id.text1,
items);
return setItems(adapter, itemSelectedListener);
}
public <T> LovelyChoiceDialog setItems(ArrayAdapter<T> adapter, OnItemSelectedListener<T> itemSelectedListener) {
choicesList.setOnItemClickListener(new ItemSelectedAdapter<>(itemSelectedListener));
choicesList.setAdapter(adapter);
return this;
}
public <T> LovelyChoiceDialog setItemsMultiChoice(T[] items, OnItemsSelectedListener<T> itemsSelectedListener) {
return setItemsMultiChoice(items, null, itemsSelectedListener);
}
public <T> LovelyChoiceDialog setItemsMultiChoice(T[] items, boolean[] selectionState, OnItemsSelectedListener<T> itemsSelectedListener) {
return setItemsMultiChoice(Arrays.asList(items), selectionState, itemsSelectedListener);
}
public <T> LovelyChoiceDialog setItemsMultiChoice(List<T> items, OnItemsSelectedListener<T> itemsSelectedListener) {
return setItemsMultiChoice(items, null, itemsSelectedListener);
}
public <T> LovelyChoiceDialog setItemsMultiChoice(List<T> items, boolean[] selectionState, OnItemsSelectedListener<T> itemsSelectedListener) {
ArrayAdapter<T> adapter = new ArrayAdapter<>(getContext(),
R.layout.dialog_item_simple_text_multichoice, android.R.id.text1,
items);
return setItemsMultiChoice(adapter, selectionState, itemsSelectedListener);
}
public <T> LovelyChoiceDialog setItemsMultiChoice(ArrayAdapter<T> adapter, OnItemsSelectedListener<T> itemsSelectedListener) {
return setItemsMultiChoice(adapter, null, itemsSelectedListener);
}
public <T> LovelyChoiceDialog setItemsMultiChoice(ArrayAdapter<T> adapter, boolean[] selectionState, OnItemsSelectedListener<T> itemsSelectedListener) {
LayoutInflater inflater = LayoutInflater.from(getContext());
View confirmBtnContainer = inflater.inflate(R.layout.dialog_item_footer_confirm, null);
confirmButton = (TextView) confirmBtnContainer.findViewById(R.id.ld_btn_confirm);
confirmButton.setOnClickListener(new ItemsSelectedAdapter<>(itemsSelectedListener));
choicesList.addFooterView(confirmBtnContainer);
ListView choicesList = findView(R.id.ld_choices);
choicesList.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE);
choicesList.setAdapter(adapter);
if (selectionState != null) {
for (int i = 0; i < selectionState.length; i++) {
choicesList.setItemChecked(i, selectionState[i]);
}
}
return this;
}
public LovelyChoiceDialog setConfirmButtonText(#StringRes int text) {
return setConfirmButtonText(string(text));
}
public LovelyChoiceDialog setConfirmButtonText(String text) {
if (confirmButton == null) {
throw new IllegalStateException(string(R.string.ex_msg_dialog_choice_confirm));
}
confirmButton.setText(text);
return this;
}
public LovelyChoiceDialog setConfirmButtonColor(int color) {
if (confirmButton == null) {
throw new IllegalStateException(string(R.string.ex_msg_dialog_choice_confirm));
}
confirmButton.setTextColor(color);
return this;
}
#Override
void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
if (isMultiChoiceList()) {
ListAdapter adapter = choicesList.getAdapter();
boolean[] checkedStates = new boolean[adapter.getCount()];
SparseBooleanArray checkedPositions = choicesList.getCheckedItemPositions();
for (int i = 0; i < checkedPositions.size(); i++) {
if (checkedPositions.valueAt(i)) {
checkedStates[checkedPositions.keyAt(i)] = true;
}
}
outState.putBooleanArray(KEY_ITEM_CHECKED_STATES, checkedStates);
}
}
#Override
void restoreState(Bundle savedState) {
super.restoreState(savedState);
if (isMultiChoiceList()) {
boolean[] checkedStates = savedState.getBooleanArray(KEY_ITEM_CHECKED_STATES);
if (checkedStates == null) {
return;
}
for (int index = 0; index < checkedStates.length; index++) {
choicesList.setItemChecked(index, checkedStates[index]);
}
}
}
#Override
protected int getLayout() {
return R.layout.dialog_choice;
}
private boolean isMultiChoiceList() {
return choicesList.getChoiceMode() == AbsListView.CHOICE_MODE_MULTIPLE;
}
public interface OnItemSelectedListener<T> {
void onItemSelected(int position, T item);
}
public interface OnItemsSelectedListener<T> {
void onItemsSelected(List<Integer> positions, List<T> items);
}
private class ItemSelectedAdapter<T> implements AdapterView.OnItemClickListener {
private OnItemSelectedListener<T> adaptee;
private ItemSelectedAdapter(OnItemSelectedListener<T> adaptee) {
this.adaptee = adaptee;
}
#Override
#SuppressWarnings("unchecked")
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
if (adaptee != null) {
adaptee.onItemSelected(position, (T) parent.getItemAtPosition(position));
}
dismiss();
}
}
private class ItemsSelectedAdapter<T> implements View.OnClickListener {
private OnItemsSelectedListener<T> adaptee;
private ItemsSelectedAdapter(OnItemsSelectedListener<T> adaptee) {
this.adaptee = adaptee;
}
#Override
#SuppressWarnings("unchecked")
public void onClick(View v) {
if (adaptee != null) {
SparseBooleanArray checkedItemPositions = choicesList.getCheckedItemPositions();
List<T> selectedItems = new ArrayList<>(checkedItemPositions.size());
List<Integer> selectedPositions = new ArrayList<>(checkedItemPositions.size());
ListAdapter adapter = choicesList.getAdapter();
for (int index = 0; index < adapter.getCount(); index++) {
if (checkedItemPositions.get(index)) {
selectedPositions.add(index);
selectedItems.add((T) adapter.getItem(index));
}
}
adaptee.onItemsSelected(selectedPositions, selectedItems);
}
dismiss();
}
}
}
LovelyDialogCompat.java
public class LovelyDialogCompat {
/**
* If you don't want to change implemented interfaces when migrating from standard dialogs
* to LovelyDialogs - use this method.
*/
public static View.OnClickListener wrap(Dialog.OnClickListener listener) {
return new DialogOnClickListenerAdapter(listener);
}
static class DialogOnClickListenerAdapter implements View.OnClickListener {
private Dialog.OnClickListener adapted;
DialogOnClickListenerAdapter(DialogInterface.OnClickListener adapted) {
this.adapted = adapted;
}
public void onClick(DialogInterface dialogInterface, int which) {
if (adapted != null) {
adapted.onClick(dialogInterface, which);
}
}
#Override
public void onClick(View v) {
}
}
}
LovelySaveStateHandler.java
public class LovelySaveStateHandler {
private static final String KEY_DIALOG_ID = "id";
private SparseArray<WeakReference<AbsLovelyDialog<?>>> handledDialogs;
public LovelySaveStateHandler() {
handledDialogs = new SparseArray<>();
}
public static boolean wasDialogOnScreen(Bundle savedInstanceState) {
return savedInstanceState.keySet().contains(KEY_DIALOG_ID);
}
public static int getSavedDialogId(Bundle savedInstanceState) {
return savedInstanceState.getInt(KEY_DIALOG_ID, -1);
}
public void saveInstanceState(Bundle outState) {
for (int index = handledDialogs.size() - 1; index >= 0; index--) {
WeakReference<AbsLovelyDialog<?>> dialogRef = handledDialogs.valueAt(index);
if (dialogRef.get() == null) {
handledDialogs.remove(index);
continue;
}
AbsLovelyDialog<?> dialog = dialogRef.get();
if (dialog.isShowing()) {
dialog.onSaveInstanceState(outState);
outState.putInt(KEY_DIALOG_ID, handledDialogs.keyAt(index));
return;
}
}
}
void handleDialogStateSave(int id, AbsLovelyDialog<?> dialog) {
handledDialogs.put(id, new WeakReference<AbsLovelyDialog<?>>(dialog));
}
}
I Have implemented the ListView with Custom Adopter class and Multiple check box selection . Its working fine . After that I have given search the name in ListView. If I checked row item then I search the name in search , Search positioned was changed . Kindly help me to fix this.
Model Class
public class FullUser {
String name=null;
String id=null;
boolean checked;
public FullUser(String name, String id,boolean checked){
this.name=name;
this.id = id;
this.checked = checked;
}
public String getName(){
return this.name;
}
public void setName(String name){
this.name = name;
}
public String getId(){
return this.id;
}
public void setId(String id){
this.id = id;
}
public Boolean getChecked(){
return this.checked;
}
public void setChecked(Boolean checked){
this.checked = checked;
}
#Override
public String toString() {
return this.name;
}
}
Adapter Class
public class FullUserAdapter extends ArrayAdapter<FullUser> {
private ArrayList<FullUser> originalList;
private ArrayList<FullUser> fullUsers;
private SubjectFilter filter;
public FullUserAdapter(Context context, int resource, ArrayList<FullUser> fullUsers) {
super(context, resource, fullUsers);
this.fullUsers = new ArrayList<FullUser>();
this.fullUsers.addAll(fullUsers);
this.originalList = new ArrayList<FullUser>();
this.originalList.addAll(fullUsers);
}
#Override
public int getCount() {
return fullUsers.size();
}
#Override
public FullUser getItem(int position) {
return fullUsers.get(position);
}
#Override
public long getItemId(int position) {
return position;
}
#Override
public Filter getFilter() {
if (filter == null){
filter = new SubjectFilter();
}
return filter;
}
#Override
public View getView(final int position, View convertView, ViewGroup parent) {
ViewHolder holder = null;
Log.v("UserConvertView", String.valueOf(position));
View row;
if (convertView == null) {
row = LayoutInflater.from(getContext()).inflate(R.layout.list_row_with_checkbox, parent, false);
}else{
row = convertView;
}
holder = new ViewHolder();
holder.name_view = (TextView) row.findViewById(R.id.nameText);
holder.firstchar_view = (TextView) row.findViewById(R.id.first_char);
holder.groupid = (TextView) row.findViewById(R.id.rowid);
holder.checkBox =(CheckBox) row.findViewById(R.id.cbBox);
final FullUser group =getItem(position);
holder.groupid.setText(group.getId());
//holder.checkBox.setChecked(checkedHolder[position]);
String communityname_text = group.getName();
holder.name_view.setText(group.getName());
String firstchar = communityname_text.substring(0, 1);
holder.firstchar_view.setText(firstchar);
holder.checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
#Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if(isChecked == true)
group.setChecked(true);
else
group.setChecked(false);
}
});
row.setTag(holder);
return row;
}
private class SubjectFilter extends Filter
{
#Override
protected FilterResults performFiltering(CharSequence constraint) {
FilterResults result = new FilterResults();
if(constraint != null && constraint.toString().length() > 0)
{
constraint = constraint.toString().toLowerCase();
ArrayList<FullUser> filteredItems = new ArrayList<FullUser>();
for(int i = 0, l = fullUsers.size(); i < l; i++)
{
FullUser group = fullUsers.get(i);
if(group.toString().toLowerCase().contains(constraint)) {
FullUser grouplistss = new FullUser(group.getName(),group.id,group.getChecked());
filteredItems.add(grouplistss);
}
}
result.count = filteredItems.size();
result.values = filteredItems;
}
else
{
synchronized(this)
{
result.values = originalList;
result.count = originalList.size();
}
}
return result;
}
#SuppressWarnings("unchecked")
#Override
protected void publishResults(CharSequence constraint,Filter.FilterResults results) {
if(results.count > 0) {
fullUsers = (ArrayList<FullUser>)results.values;
notifyDataSetChanged();
clear();
for(int i = 0, l = fullUsers.size(); i < l; i++)
add(fullUsers.get(i));
} else {
notifyDataSetInvalidated();
}
}
}
private class ViewHolder {
TextView name_view;
TextView firstchar_view;
TextView groupid;
CheckBox checkBox;
}
}
Thanks in advance.
#Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if(isChecked){
group.setChecked(true);
int pos = originalList.indexOf(group)
originalList.get(pos).setChecked(true);
fullUsers.get(position).setChecked(true);
}else{
group.setChecked(false);
int pos = originalList.indexOf(group)
originalList.get(pos).setChecked(true);
fullUsers.get(position).setChecked(false);
}
}
update your adapter use SparseBooleanArray
public class FullUserAdapter extends ArrayAdapter<FullUser> {
private ArrayList<FullUser> originalList;
private ArrayList<FullUser> fullUsers;
private SubjectFilter filter;
SparseBooleanArray booleanArray ;
public FullUserAdapter(Context context, int resource, ArrayList<FullUser> fullUsers) {
super(context, resource, fullUsers);
this.fullUsers = new ArrayList<FullUser>();
this.fullUsers.addAll(fullUsers);
this.originalList = new ArrayList<FullUser>();
this.originalList.addAll(fullUsers);
booleanArray = new SparseBooleanArray();
}
#Override
public View getView(final int position, View convertView, ViewGroup parent) {
.
.
.
final FullUser group =getItem(position);
holder.groupid.setText(group.getId());
holder.checkBox.setOnCheckedChangeListener(null);
holder.checkBox.setChecked(booleanArray.get(group.getId().hashCode(),false));
holder.checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
#Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
booleanArray.put(group.getId().hashCode(), isChecked);
}
});
.
.
.
return row;
}
public ArrayList<FullUser> getSelectedItems() {
ArrayList<FullUser> list = new ArrayList<>();
for(FullUser group:fullUsers){
if(booleanArray.get(group.getId().hashCode(), false)){
list.add(group);
}
}
return list;
};
}
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".dashboard.VoterListActivity">
<ProgressBar
android:id="#+id/reqprogressbar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:visibility="gone" />
<ListView
android:id="#+id/voter_lv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/btn_show_me"
android:divider="#null"/>
<Button
android:id="#+id/btn_show_me"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="5dp"
android:background="#drawable/n_btn"
android:text="#string/add_family_numbers"
android:visibility="gone"
android:textColor="#ffffff"
android:textSize="20sp" />
</RelativeLayout>
Java Code
public Class Actvity extends AppCompatActivity {
ProgressBar progressBar;
ListView listView;
VoterDao voterDao;
String Token, Userid, Appid, Deviceid;
MenuItem searchview;
VoterListAdapter adapter;
String pid;
VoterDatum friend;
String value;
CheckBox mCheckBox;
Button btn_show_me;
ArrayList<VoterDatum> friends;
ListView1Adapter adapter1;
VoterDatum Model;
StringBuilder stringBuilder;
String name;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_voter_list);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setTitle(R.string.voter_list);
stringBuilder = new StringBuilder();
Token = Util.getStringFromSP(this, "token");
Userid = Util.getStringFromSP(this, "user_id");
Appid = Util.getStringFromSP(this, "app_id");
Deviceid = Util.getStringFromSP(this, "device_id");
initViews();
getVoterData();
btn_show_me.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
int i = 0;
if (friends.size() == i) { //do nothing
}
while (friends.size() > i) {
int count = friends.size();
Model = friends.get(i);
if (Model.isChecked()) {
Log.i("ListActivity", "here" + friends.get(i).getCitizenId());
stringBuilder.append("," + friends.get(i).getCitizenId());
name = stringBuilder.toString();
String joinedString = Model.getCitizenId().toString();
Log.d("ls", "" + name);
name = name.substring(1);
Log.d("fs", name);
sendToServer();
}
i++; // rise i
}
}
});
}
private void sendToServer() {
Intent intent = new Intent(VoterListActivity.this, AddFamilyNuberByVoterList.class);
intent.putParcelableArrayListExtra("CheckedList", friends);
startActivity(intent);
finish();
}
private void getVoterData() {
if (Util.isNetworkAvailable(this)) {
progressBar.setVisibility(View.VISIBLE);
SendRequestToServer();
} else {
progressBar.setVisibility(View.GONE);
Snackbar.make(listView, R.string.no_connection, Snackbar.LENGTH_SHORT).show();
return;
}
}
private void SendRequestToServer() {
try {
RegistrationApi api = ServiceGenerator.createService(RegistrationApi.class);
retrofit2.Call<VoterDao> call = api.togetVoters(Userid, Token, Appid, Deviceid);
call.enqueue(new Callback<VoterDao>() {
#Override
public void onResponse(Call<VoterDao> call, Response<VoterDao> response) {
if (response.isSuccessful()) {
voterDao = response.body();
if (voterDao.getAddData().getStatus().equals(1)) {
searchview.setVisible(true);
progressBar.setVisibility(View.GONE);
friends = (ArrayList<VoterDatum>) voterDao.getAddData().getData();
adapter1 = new ListView1Adapter(getApplicationContext(), R.layout.list_voter, friends);
listView.setAdapter(adapter1);
btn_show_me.setVisibility(View.VISIBLE);
} else {
searchview.setVisible(false);
progressBar.setVisibility(View.GONE);
Snackbar.make(listView, R.string.no_data_found, Snackbar.LENGTH_SHORT).show();
}
} else {
searchview.setVisible(false);
progressBar.setVisibility(View.GONE);
Snackbar.make(listView, R.string.no_data_found + response.message(), Snackbar.LENGTH_SHORT).show();
}
}
#Override
public void onFailure(Call<VoterDao> call, Throwable t) {
try {
searchview.setVisible(false);
progressBar.setVisibility(View.GONE);
Snackbar.make(listView, "" + t.getMessage(), Snackbar.LENGTH_SHORT).show();
Log.d("message", "" + t.getMessage());
System.out.println("onFAilureExecute" + t.getMessage());
if (t != null)
t.printStackTrace();
} catch (Throwable th) {
th.printStackTrace();
}
}
});
} catch (Exception e) {
e.printStackTrace();
}
}
private void initViews() {
progressBar = findViewById(R.id.reqprogressbar);
listView = findViewById(R.id.voter_lv);
btn_show_me = findViewById(R.id.btn_show_me);
}
#Override
public boolean onSupportNavigateUp() {
startActivity(new Intent(getApplicationContext(), DashboardActivity.class));
finish();
overridePendingTransition(R.anim.fade_in, R.anim.fade_out);
return true;
}
#Override
public void onBackPressed() {
startActivity(new Intent(getApplicationContext(), DashboardActivity.class));
finish();
overridePendingTransition(R.anim.fade_in, R.anim.fade_out);
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
searchview = menu.findItem(R.id.action_search);
final SearchView searchViewAndroidActionBar = (SearchView) MenuItemCompat.getActionView(searchview);
searchViewAndroidActionBar.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
#Override
public boolean onQueryTextSubmit(String query) {
return true;
}
#Override
public boolean onQueryTextChange(String newText) {
adapter1.getFilter().filter(newText);
return false;
}
});
View closeButton = searchViewAndroidActionBar.findViewById(android.support.v7.appcompat.R.id.search_close_btn);
closeButton.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
//handle click
searchViewAndroidActionBar.setIconified(true);
}
});
return super.onCreateOptionsMenu(menu);
}
#Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(LocalHelper.onAttach(base));
}
private class ListView1Adapter extends BaseAdapter {
ListView1Adapter.ViewHolder holder;
private Context activity;
private ArrayList<VoterDatum> Friends;
private ArrayList<VoterDatum> mList;
private final String TAG = ListViewAdapter.class.getSimpleName();
boolean[] checkedItems;
public ListView1Adapter(Context applicationContext, int list_voter, ArrayList<VoterDatum> list) {
this.activity = applicationContext;
this.Friends = list;
this.mList = list;
Log.i(TAG, "init adapter");
checkedItems = new boolean[mList.size()];
}
#Override
public int getCount() {
return mList.size();
}
#Override
public Object getItem(int position) {
return mList.get(position);
}
#Override
public long getItemId(int position) {
return position;
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
holder = null;
final int pos = position;
// inflate layout from xml
LayoutInflater inflater = (LayoutInflater) activity
.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
// If holder not exist then locate all view from UI file.
if (convertView == null) {
// inflate UI from XML file
convertView = inflater.inflate(R.layout.list_voter, parent, false);
// get all UI view
holder = new ListView1Adapter.ViewHolder(convertView);
// set tag for holder
convertView.setTag(holder);
} else {
// if holder created, get tag from view
holder = (ListView1Adapter.ViewHolder) convertView.getTag();
}
friend = mList.get(position);
String nameS = friend.getFirstname() + " " + friend.getLastname();
String namesS = friend.getVoterId();
String lname = friend.getLfname() + " " + friend.getLlastname();
//set Friend data to views
String Photo = friend.getPhoto();
if (Photo.isEmpty() || Photo == null) {
holder.image.setImageResource(R.mipmap.ic_launcher);
} else {
Picasso.with(activity).load(Photo).transform(new CircleTransform()).into(holder.image);
}
holder.name.setText(nameS);
holder.lanname.setText(lname);
holder.voterid_tv.setText(namesS);
holder.check.setChecked(friend.isChecked());
holder.check.setTag(friend);
holder.check.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
CheckBox cb = (CheckBox) v;
VoterDatum itemobj = (VoterDatum) cb.getTag();
if (mList.get(Integer.valueOf(pos)).isChecked()) {
cb.setSelected(false);
mList.get(Integer.valueOf(pos)).setIsChecked(false);
notifyDataSetChanged();
} else {
cb.setSelected(true);
mList.get(Integer.valueOf(pos)).setIsChecked(true);
notifyDataSetChanged();
}
}
});
return convertView;
}
private class ViewHolder {
private ImageView image;
private TextView name, lanname, voterid_tv;
private CheckBox check;
public ViewHolder(View v) {
image = v.findViewById(R.id.profile_iv);
name = (TextView) v.findViewById(R.id.name_tv);
lanname = (TextView) v.findViewById(R.id.desig_tv);
voterid_tv = (TextView) v.findViewById(R.id.voterid_tv);
check = (CheckBox) v.findViewById(R.id.chkEnable);
}
}
public Filter getFilter() {
return new Filter() {
#Override
protected FilterResults performFiltering(CharSequence constraint) {
FilterResults results = new FilterResults();
ArrayList<VoterDatum> filteredResults = null;
if (constraint.length() == 0) {
filteredResults = Friends;
} else {
filteredResults = (ArrayList<VoterDatum>) getFilteredResults(constraint.toString().toLowerCase());
}
results.values = filteredResults;
return results;
}
#Override
protected void publishResults(CharSequence charSequence, FilterResults results) {
mList = (ArrayList<VoterDatum>) results.values;
notifyDataSetChanged();
}
};
}
protected List<VoterDatum> getFilteredResults(String s) {
ArrayList<VoterDatum> results = new ArrayList<>();
for (VoterDatum item : Friends) {
String TotalSearch = item.getFirstname() + " " + item.getLastname();
if (TotalSearch.toLowerCase().contains(s) || item.getVoterId().toLowerCase().contains(s)) {
results.add(item);
}
}
return results;
}
public ArrayList<VoterDatum> getAllData() {
return mList;
}
}
}
Model Class
public class VoterDatum implements Parcelable {
#SerializedName("citizen_id")
#Expose
private String citizenId;
private boolean isChecked;
public static final Parcelable.Creator<VoterDatum> CREATOR = new Parcelable.Creator<VoterDatum>() {
public VoterDatum createFromParcel(Parcel in) {
return new VoterDatum(in);
}
public VoterDatum[] newArray(int size) {
return new VoterDatum[size];
}
};
public VoterDatum(Parcel in) {
this.citizenId = in.readString();
this.isChecked = in.readByte() != 0;
}
#Override
public int describeContents() {
return 0;
}
#Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(this.citizenId);
dest.writeByte((byte) (this.isChecked ? 1 : 0));
}
public VoterDatum(String citizenId, boolean gender) {
this.citizenId = citizenId;
this.isChecked = false; // not selected when create
}
#SerializedName("status")
#Expose
private String status;
#SerializedName("firstname")
#Expose
private String firstname;
#SerializedName("lastname")
public boolean isChecked() {
return isChecked;
}
public void setIsChecked(boolean isChecked) {
this.isChecked = isChecked;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getCitizenId() {
return citizenId;
}
public void setCitizenId(String citizenId) {
this.citizenId = citizenId;
}
public String getFirstname() {
return firstname;
}
public void setFirstname(String firstname) {
this.firstname = firstname;
}
public String getLastname() {
return lastname;
}
public void setLastname(String lastname) {
this.lastname = lastname;
}
public String getLfname() {
return lfname;
}
public void setLfname(String lfname) {
this.lfname = lfname;
}
}
Get Data From Other Class
public class ACtivity extends AppCompatActivity implements View.OnClickListener {
String Mvoterid;
GPSTracker gps;
String Token, Userid, Deviceid, Appid, Language;
Button submit_btn;
ProgressBar progressBar;
AddFamilynumberbyvoterDao addFamilynumberbyvoterDao;
// ArrayList<VoterDatum> checkedList;
List<VoterDatum> checkedList;
LinearLayout container;
VoterDatum Model;
ListView list_item;
String join;
int position;
String userName;
String name;
StringBuilder stringBuilder;
#RequiresApi(api = Build.VERSION_CODES.O)
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_add_family_nuber_by_voter_list);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setTitle(R.string.add_family_numbers);
VoterID = getIntent().getStringExtra("voterIDs");
stringBuilder= new StringBuilder();
checkedList = new ArrayList<VoterDatum>(); // initializing list
container = (LinearLayout) findViewById(R.id.layout);
getLocation();
initViews();
initListeners();
getDataFromIntent();
generateDataToContainerLayout();
}
#RequiresApi(api = Build.VERSION_CODES.O)
#SuppressLint("InflateParams")
private void generateDataToContainerLayout() {
int i = 0;
if (checkedList.size() == i) { //do nothing
}
while (checkedList.size() > i) {
int count = checkedList.size();
Model = checkedList.get(i);
if (Model.isChecked()) {
Log.i("ListActivity", "here" + checkedList.get(i).getCitizenId());
stringBuilder.append(","+checkedList.get(i).getCitizenId());
name=stringBuilder.toString();
String joinedString = Model.getCitizenId().toString();
Log.d("ls", "" + name);
name=name.substring(1);
Log.d("fs",name);
}
i++; // rise i
}
}
private void getDataFromIntent() {
checkedList = getIntent().getParcelableArrayListExtra("CheckedList");
}