My listview is not displaying its content - java

Here is the code for MainActivity
How to view listview products please suggest me as soon as possible
public class ProductList extends AppCompatActivity {
public static ArrayList<ItemProductList> values1=new ArrayList<ItemProductList>();
ListView list_productlist;
Context context = this;
public ItenProductAdapter mAdapter;
String category,name1;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_product_list);
list_productlist = (ListView) findViewById(R.id.list_productlist);
category=getIntent().getStringExtra("category");
name1=getIntent().getStringExtra("name");
loadJSON();
mAdapter= new ItenProductAdapter(context,values1);
list_productlist.setAdapter(mAdapter);
}
private void loadJSON() {
StringRequest jsonObjReq = new StringRequest(Request.Method.POST,
"http://arshinfosystems.co.in/demo/AoneRubber/productlist.php",
new Response.Listener<String>() {
#Override
public void onResponse(String response) {
try {
JSONObject jObject = new JSONObject(response);
JSONArray jsonArray = jObject.getJSONArray("cart");
for (int i = 0; i < jsonArray.length(); i++) {
JSONObject jbjct = jsonArray.getJSONObject(i);
ItemProductList itemListModel = new ItemProductList();
itemListModel.thickness1 = jbjct.getString("thickness");
itemListModel.id1 = jbjct.getString("id");
itemListModel.price1 = jbjct.getString("price");
itemListModel.category1 = jbjct.getString("category");
itemListModel.name1=jbjct.getString("name");
itemListModel.sr_no=jbjct.getString("sr_no");
values1.add(itemListModel);
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(ProductList.this, error.toString(), Toast.LENGTH_SHORT).show();
}
}) {
#Override
protected Map<String, String> getParams() {
Map<String, String> params = new HashMap<String, String>();
params.put("category", category);
params.put("name", name1);
return params;
}
};
jsonObjReq.setRetryPolicy(new DefaultRetryPolicy(50000,
DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
RequestQueue requestQueue = Volley.newRequestQueue(this);
requestQueue.add(jsonObjReq);
}
}
Here is the code for Adapter
How to view listview products please suggest me as soon as possible please guys
public class ItenProductAdapter extends BaseAdapter {
public static ArrayList<ItemProductList> list1;
String idValues = "";
Context context;
public static Integer total;
Bitmap mIcon11 = null;
ViewHolder holder;
public ItenProductAdapter(Context context, ArrayList<ItemProductList> list) {
super();
this.list1 = list;
this.context = context;
}
#Override
public int getCount() {
return 0;
}
#Override
public Object getItem(int position) {
return null;
}
#Override
public long getItemId(int position) {
return 0;
}
static class ViewHolder {
TextView txt_sr_no;
TextView txt_thickness;
TextView txt_rates;
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
holder=new ViewHolder();
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.product_list_item, null);
holder.txt_sr_no= (TextView) convertView.findViewById(R.id.txt_sr_no);
holder.txt_thickness= (TextView) convertView.findViewById(R.id.txt_thickness);
holder.txt_rates= (TextView) convertView.findViewById(R.id.txt_rates);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
holder.txt_sr_no.setText(list1.get(position).sr_no+")");
holder.txt_thickness.setText(""+ list1.get(position).thickness1);
holder.txt_rates.setText("RS "+list1.get(position).price1);
return convertView;
}
}

In your code method getCount() returns 0. Change it to
public int getCount() {
return list.size();
}
BTW its better to extend ArrayAdapter.

Your getCount function of your adapter always returns that is has no items
Change this
#Override
public int getCount() {
return 0;
}
to something like this
#Override
public int getCount() {
if (list1 != null) {
return list1.size();
}
return 0;
}

Try This
onCreate
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_product_list);
list_productlist = (ListView) findViewById(R.id.list_productlist);
category=getIntent().getStringExtra("category");
name1=getIntent().getStringExtra("name");
loadJSON();
}
Then the onResponse
#Override
public void onResponse(String response) {
try {
JSONObject jObject = new JSONObject(response);
JSONArray jsonArray = jObject.getJSONArray("cart");
for (int i = 0; i < jsonArray.length(); i++) {
JSONObject jbjct = jsonArray.getJSONObject(i);
ItemProductList itemListModel = new ItemProductList();
itemListModel.thickness1 = jbjct.getString("thickness");
itemListModel.id1 = jbjct.getString("id");
itemListModel.price1 = jbjct.getString("price");
itemListModel.category1 = jbjct.getString("category");
itemListModel.name1=jbjct.getString("name");
itemListModel.sr_no=jbjct.getString("sr_no");
values1.add(itemListModel);
}
//Check if list is empty or not
if(values1.size()>0){
mAdapter= new ItenProductAdapter(context,values1);
list_productlist.setAdapter(mAdapter);
}
} catch (JSONException e) {
e.printStackTrace();
}
}

try this
#Override
public void onResponse(String response) {
try {
JSONObject jObject = new JSONObject(response);
JSONArray jsonArray = jObject.getJSONArray("cart");
for (int i = 0; i < jsonArray.length(); i++) {
JSONObject jbjct = jsonArray.getJSONObject(i);
ItemProductList itemListModel = new ItemProductList();
itemListModel.thickness1 = jbjct.getString("thickness");
itemListModel.id1 = jbjct.getString("id");
itemListModel.price1 = jbjct.getString("price");
itemListModel.category1 = jbjct.getString("category");
itemListModel.name1=jbjct.getString("name");
itemListModel.sr_no=jbjct.getString("sr_no");
values1.add(itemListModel);
}
mAdapter.setList(values1);
mAdapter.notifyDataSetChanged();
}
Adapter Class
public class ItenProductAdapter extends BaseAdapter {
public static ArrayList<ItemProductList> list1;
String idValues = "";
Context context;
public static Integer total;
Bitmap mIcon11 = null;
ViewHolder holder;
public ItenProductAdapter(Context context, ArrayList<ItemProductList> list) {
super();
this.list1 = list;
this.context = context;
}
public void setList(ArrayList<ItemProductList> list){
this.list1 = list;
}
#Override
public int getCount() {
return list1.size();
}
#Override
public Object getItem(int position) {
return null;
}
#Override
public long getItemId(int position) {
return 0;
}
static class ViewHolder {
TextView txt_sr_no;
TextView txt_thickness;
TextView txt_rates;
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
holder=new ViewHolder();
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.product_list_item, null);
holder.txt_sr_no= (TextView) convertView.findViewById(R.id.txt_sr_no);
holder.txt_thickness= (TextView) convertView.findViewById(R.id.txt_thickness);
holder.txt_rates= (TextView) convertView.findViewById(R.id.txt_rates);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
holder.txt_sr_no.setText(list1.get(position).sr_no+")");
holder.txt_thickness.setText(""+ list1.get(position).thickness1);
holder.txt_rates.setText("RS "+list1.get(position).price1);
return convertView;
}
}

Related

JSONArray data won't show on Fragment

I'm having problems with showing JSONArray data on the Fragment. I am verified my links, Strings etc. But on the Debug console my request showing correct. I am suspecting JSONArray request but i can't find any errors.
Please, help!
D/Request::: 010-8470-0486
010-8472-0964
010-8474-2372
D/Request::: 010-8475-0089
D/Request::: 010-8475-7585
010-8478-0007
D/Request::: 010-8478-0573
010-8479-0311
010-8479-9234
D/Request::: 010-8481-2030
This is my Fragment
public class FragmentDB extends Fragment {
private View v;
private RecyclerView recyclerView;
private String url = "http://www.example.com/api.php";
private List<ModelDB> modelDBList;
public FragmentDB() {
}
#SuppressWarnings("UnnecessaryLocalVariable")
#Nullable
#Override
public View onCreateView(#NonNull LayoutInflater inflater, #Nullable ViewGroup container, Bundle savedInstanceState) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (Objects.requireNonNull(getActivity()).checkSelfPermission(Manifest.permission.READ_CALL_LOG) != PackageManager.PERMISSION_GRANTED &&
getActivity().checkSelfPermission(Manifest.permission.READ_CONTACTS) != PackageManager.PERMISSION_GRANTED &&
getActivity().checkSelfPermission(Manifest.permission.READ_PHONE_STATE) != PackageManager.PERMISSION_GRANTED)
return v;
} else {
Intent i10 = new Intent(getActivity(), PermissionActivity.class);
startActivity(i10);
Objects.requireNonNull(getActivity()).finish();
}
v = inflater.inflate(R.layout.frag_db, container, false);
recyclerView = v.findViewById(R.id.rv_db);
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getContext());
RecyclerView.LayoutManager layoutManager = linearLayoutManager;
recyclerView.setLayoutManager(layoutManager);
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(recyclerView.getContext(), linearLayoutManager.getOrientation());
modelDBList = new ArrayList<>();
DbRvAdapter adapter = new DbRvAdapter(getContext(), modelDBList);
recyclerView.setAdapter(adapter);
adapter.notifyDataSetChanged();
recyclerView.addItemDecoration(dividerItemDecoration);
recyclerView.setHasFixedSize(true);
Objects.requireNonNull(getActivity()).getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
getDBLogs();
return v;
}
#SuppressWarnings({"LogNotTimber", "deprecation"})
private void getDBLogs() {
JsonArrayRequest jsonArrayRequest = new JsonArrayRequest(url, new Response.Listener<JSONArray>() {
#Override
public void onResponse(JSONArray response) {
// Do something with the response
try {
for ( int i = 0; i < response.length(); i++) {
JSONObject obj = response.getJSONObject(i);
ModelDB dblist = new ModelDB();
dblist.setPhone_number(obj.getString("phone_number"));
dblist.setInfo1(obj.getString("info1"));
modelDBList.add(dblist);
Log.d("Request:: ", obj.getString("phone_number"));
}
} catch(JSONException e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
// Handle error
Log.e("Volley", error.toString());
}
});
RequestQueue rq = Volley.newRequestQueue(Objects.requireNonNull(getActivity()).getApplicationContext());
rq.add(jsonArrayRequest);
}
}
and ModelDB class
public class ModelDB {
public String phone_number;
public String info1;
public ModelDB() {
}
public ModelDB(String phone_number, String info1) {
this.phone_number = phone_number;
this.info1 = info1;
}
public String getPhone_number() {
return phone_number;
}
public void setPhone_number(String phone_number) {
this.phone_number = phone_number;
}
public String getInfo1() {
return info1;
}
public void setInfo1(String info1) {
this.info1 = info1;
}
}
and adapter class
public class DbRvAdapter extends RecyclerView.Adapter<DbRvAdapter.ViewHolder> {
public static final String KEY_DBPHONENUMBER = "phone_number";
public static final String KEY_DBINFO = "info1";
private Context context;
private List<ModelDB> list;
public DbRvAdapter(Context context, List<ModelDB> list) {
this.context = context;
this.list = list;
}
#NonNull
#Override
public ViewHolder onCreateViewHolder(#NonNull ViewGroup parent, int viewType) {
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.single_db, parent, false);
return new ViewHolder(v);
}
#SuppressWarnings("RecyclerView")
#Override
public void onBindViewHolder(#NonNull ViewHolder holder, final int position) {
final ModelDB modelDB = list.get(position);
holder.textDBP.setText(modelDB.getPhone_number());
holder.textInfo1.setText(String.valueOf(modelDB.getInfo1()));
holder.relativeLayout.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
ModelDB modelDB1 = list.get(position);
Intent skipIntent = new Intent(v.getContext(), NumberActivity.class);
skipIntent.putExtra(KEY_DBINFO, modelDB1.getInfo1());
skipIntent.putExtra(KEY_DBPHONENUMBER, modelDB1.getPhone_number());
v.getContext().startActivity(skipIntent);
}
});
}
#Override
public int getItemCount() {
return list.size();
}
public class ViewHolder extends RecyclerView.ViewHolder {
public TextView textDBP, textInfo1;
public RelativeLayout relativeLayout;
public ViewHolder(View itemView) {
super(itemView);
textDBP = itemView.findViewById(R.id.tv_number);
textInfo1 = itemView.findViewById(R.id.tv_dbinfo);
}
}
}
Sorry for my bad English.
notify you adapter after the for loop body and declare the adapter globally
for ( int i = 0; i < response.length(); i++) {
............
modelDBList.add(dblist);
}
if(dblist != null and dblist.size() > 0){
adapter.notifyDataSetChanged();
}
It looks like you didn't update list of modelDB's inside adapter after the parsing of a network call result.

How to populate ListView in a fragment from PHP JSON data?

I have a fragment (homePageFrag) containing a ListView . When I'm trying to populate it using JSON data from a URL, it's not working. The ListView is being empty. However, it is showing up when I'm giving static data from an ArrayList.
What I want to achieve is populating the ListView inside a Fragment from JSON data obtained from a URL. The HP_JSON_Download is working as intended was I'm using a ListView in a Activity, but in the fragment, its not showing up any data.
homePageFrag.java
public class homePageFrag extends Fragment implements HP_JSON_Download.download_complete {
boolean open = false; Context applicationContext;
public ListView list;
public ArrayList<HPEntity> countries = new ArrayList<HPEntity>();
public HP_ListAdapter adapter;
private final String bus_id[] = {"a1"};
private final String bus_destination[] = {"A1"};
#Nullable
#Override
public View onCreateView(LayoutInflater inflater, #Nullable ViewGroup container, #Nullable Bundle savedInstanceState) {
//returning our layout file
View view = inflater.inflate(R.layout.homepage_lv, container, false);
list = (ListView) view.findViewById(R.id.homepageListView);
adapter = new HP_ListAdapter(this);
list.setAdapter(adapter);
HP_JSON_Download download_data = new HP_JSON_Download((HP_JSON_Download.download_complete) this);
download_data.download_data_from_link("http://www.xyz.in/MyApi/Api.php");
return view;
}
#Override
public void onViewCreated(View view, #Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
//you can set the title for your toolbar here for different fragments different titles
getActivity().setTitle("E-RTC");
}
public void get_data(String data) {
Toast.makeText(getApplicationContext(),"xx",Toast.LENGTH_SHORT).show();
try {
JSONArray data_array=new JSONArray(data);
for (int i = 0 ; i < data_array.length() ; i++) {
JSONObject obj=new JSONObject(data_array.get(i).toString());
HPEntity add=new HPEntity();
add.name = obj.getString("id");
add.code = obj.getString("name");
countries.add(add);
}
adapter.notifyDataSetChanged();
} catch (JSONException e) {
e.printStackTrace();
}
}
public Context getApplicationContext() {
return applicationContext;
}
}
HP_ListAdapter.java
public class HP_ListAdapter extends BaseAdapter {
homePageFrag main;
Context mContext;
public HP_ListAdapter(Context mContext) {
this.mContext = mContext;
}
HP_ListAdapter(homePageFrag main) {
this.main = main;
}
#Override
public int getCount() {
return main.countries.size();
}
#Override
public Object getItem(int position) {
return null;
}
#Override
public long getItemId(int position) {
return 0;
}
static class ViewHolderItem {
TextView name;
TextView code;
}
#Override
public View getView(int position, View convertView, ViewGroup parent){
ViewHolderItem holder = new ViewHolderItem();
if (convertView == null) {
LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.homepage_item, null);
holder.name = (TextView) convertView.findViewById(R.id.busID);
holder.code = (TextView) convertView.findViewById(R.id.busNAME);
convertView.setTag(holder);
} else {
holder = (ViewHolderItem) convertView.getTag();
}
holder.name.setText(this.main.countries.get(position).name);
holder.code.setText(this.main.countries.get(position).code);
return convertView;
}
}
HPEntity.java
public class HPEntity {
String name;
String code;
}
HP_JSON_Download.java
public class HP_JSON_Download implements Runnable {
public download_complete caller;
public interface download_complete {
void get_data(String data);
}
HP_JSON_Download(download_complete caller) {
this.caller = caller;
}
private String link;
public void download_data_from_link(String link) {
this.link = link;
Thread t = new Thread(this);
t.start();
}
public void run() {
threadMsg(download(this.link));
}
private void threadMsg(String msg) {
if (!msg.equals(null) && !msg.equals("")) {
Message msgObj = handler.obtainMessage();
Bundle b = new Bundle();
b.putString("message", msg);
msgObj.setData(b);
handler.sendMessage(msgObj);
}
}
private final Handler handler = new Handler() {
public void handleMessage(Message msg) {
String Response = msg.getData().getString("message");
caller.get_data(Response);
}
};
public static String download(String url) {
URL website;
StringBuilder response = null;
try {
website = new URL(url);
HttpURLConnection connection = (HttpURLConnection) website.openConnection();
connection.setRequestProperty("charset", "utf-8");
BufferedReader in = new BufferedReader(
new InputStreamReader(
connection.getInputStream()));
response = new StringBuilder();
String inputLine;
while ((inputLine = in.readLine()) != null)
response.append(inputLine);
in.close();
} catch (Exception e) {
return "";
}
return response.toString();
}
}
I would suggest you to modify your adapter like this.
public class HP_ListAdapter extends BaseAdapter {
public ArrayList<HPEntity> countries = new ArrayList<HPEntity>();
Context mContext;
public HP_ListAdapter(Context mContext, ArrayList<HPEntity> countries) {
this.mContext = mContext;
this.countries = countries;
}
#Override
public int getCount() {
return countries.size();
}
#Override
public Object getItem(int position) {
return countries.get(position);
}
#Override
public long getItemId(int position) {
return position;
}
static class ViewHolderItem {
TextView name;
TextView code;
}
#Override
public View getView(int position, View convertView, ViewGroup parent){
ViewHolderItem holder = new ViewHolderItem();
if (convertView == null) {
LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.homepage_item, null);
holder.name = (TextView) convertView.findViewById(R.id.busID);
holder.code = (TextView) convertView.findViewById(R.id.busNAME);
convertView.setTag(holder);
} else {
holder = (ViewHolderItem) convertView.getTag();
}
holder.name.setText(this.countries.get(position).name);
holder.code.setText(this.countries.get(position).code);
return convertView;
}
}
Now initialize your adapter from your onCreateView function in your Fragment like this. You are passing the wrong context to your adapter initialization by using this. You should have used getActivity() instead.
adapter = new HP_ListAdapter(getActivity(), countries);

Search an data listview using edittext

I'm creating a Movie Catalog app using themoviedb API. How can I implement search using EditText?
I have a list view that contains the movie info.
App screenshot:
Now I want to use the EditText to find another movie, and the list view updated. How do I do that?
My loader:
public class MyAsyncTaskLoader extends AsyncTaskLoader<ArrayList<MovieItem>> {
public ArrayList<MovieItem> mData;
public boolean hasResult = false;
public MyAsyncTaskLoader(final Context context) {
super(context);
onContentChanged();
Log.d("INIT ASYNCLOADER","1");
}
#Override
protected void onStartLoading() {
Log.d("Content Changed","1");
if (takeContentChanged())
forceLoad();
else if (hasResult)
deliverResult(mData);
}
#Override
public void deliverResult(final ArrayList<MovieItem> data) {
mData = data;
hasResult = true;
super.deliverResult(data);
}
#Override
protected void onReset() {
super.onReset();
onStopLoading();
if (hasResult) {
onReleaseResources(mData);
mData = null;
hasResult = false;
}
}
public static String Search = "Avengers";
public static String API_KEY = "f00e74c69ff0512cf9e5bf128569f6b5";
#Override
public ArrayList<MovieItem> loadInBackground() {
Log.d("LOAD BG","1");
SyncHttpClient client = new SyncHttpClient();
final ArrayList<MovieItem> movieItemses = new ArrayList<>();
final String url = "https://api.themoviedb.org/3/search/movie?api_key="+API_KEY+"&language=en-US&query="+Search;
client.get(url, new AsyncHttpResponseHandler() {
#Override
public void onStart() {
super.onStart();
setUseSynchronousMode(true);
}
#Override
public void onSuccess(int statusCode, Header[] headers,
byte[] responseBody) {
try {
String result = new String(responseBody);
JSONObject responseObject = new JSONObject(result);
JSONArray list = responseObject.getJSONArray("results");
for (int i = 0 ; i < list.length() ; i++){
JSONObject movie = list.getJSONObject(i);
MovieItem movieItems = new MovieItem(movie);
movieItemses.add(movieItems);
}
Log.d("REQUEST SUCCESS","1");
}catch (Exception e){
e.printStackTrace();
Log.d("REQUEST FAILED","1");
}
}
#Override
public void onFailure(int statusCode, Header[] headers,
byte[] responseBody, Throwable error) {
}
});
for (int i = 0 ; i< movieItemses.size() ; i++){
Log.d("Title",movieItemses.get(i).getTitle());
}
Log.d("BEFORE RETURN","1");
return movieItemses;
}
protected void onReleaseResources(ArrayList<MovieItem> data) {
//nothing to do.
}
public ArrayList<MovieItem> getResult() {
return mData;
}
}
My adapter:
public class MovieAdapter extends BaseAdapter {
private ArrayList<MovieItem> mData = new ArrayList<>();
private LayoutInflater mInflater;
private Context context;
Activity activity;
private String urlConfig ;
public MovieAdapter(Context context) {
this.context = context;
mInflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
public void setData(ArrayList<MovieItem> items){
mData = items;
notifyDataSetChanged();
}
public void clearData(){
mData.clear();
}
#Override
public int getItemViewType(int position) {
return 0;
}
#Override
public int getViewTypeCount() {
return 1;
}
#Override
public int getCount() {
return mData.size();
}
#Override
public MovieItem getItem(int position) {
return mData.get(position);
}
#Override
public long getItemId(int position) {
return position;
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder = null;
if (convertView == null) {
holder = new ViewHolder();
convertView = mInflater.inflate(R.layout.item_row_film, null);
holder.textViewuJudul= (TextView)convertView.findViewById(R.id.tv_judul);
holder.textViewDescription = (TextView)convertView.findViewById(R.id.tv_deskripsi);
holder.textViewRate = (TextView)convertView.findViewById(R.id.tv_rate);
holder.imgPoster = (ImageView) convertView.findViewById(R.id.img_poster);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
holder.textViewuJudul.setText(mData.get(position).getTitle());
holder.textViewDescription.setText(mData.get(position).getDescription());
holder.textViewRate .setText(mData.get(position).getRate());
Picasso.with(context).load(mData.get(position).getImgurl()).into(holder.imgPoster);
return convertView;
}
private class ViewHolder {
public TextView textViewuJudul;
public TextView textViewDescription;
public TextView textViewRate;
public ImageView imgPoster;
}}
The item:
public class MovieItem {
public static String POSTER_BASE_URL = "http://image.tmdb.org/t/p/";
private int id;
private String title;
private String description;
private String rate;
private String imgurl;
public MovieItem(JSONObject object){
try {
String title = object.getString("title");
String description = object.getString("overview");
double movieRatet = object.getDouble("vote_average");
String movieRate = new DecimalFormat("#.#").format(movieRatet);
String releaseDate = object.getString("release_date");
String posterUrl = object.getString("poster_path");
posterUrl = POSTER_BASE_URL + "w185" + posterUrl;
description = description.length() > 64 ? description.substring(0,64)+"...":description;
Log.d("movie poster", posterUrl);
Log.d("movie title ", title);
Log.d("movie description ", description);
Log.d("movie release ", releaseDate);
this.title = title;
this.description = description;
this.rate = releaseDate;
this.imgurl = posterUrl;
}catch (Exception e){
e.printStackTrace();
}
}
My MainActivity:
public class MainActivity extends AppCompatActivity implements LoaderManager.LoaderCallbacks<ArrayList<MovieItem>>
,View.OnClickListener{
ListView listView;
MovieAdapter adapter;
MyAsyncTaskLoader myAsyncTaskLoader;
private TextView edt_cari;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
edt_cari = (TextView) findViewById(R.id.edt_cari);
adapter = new MovieAdapter(this);
adapter.notifyDataSetChanged();
listView = (ListView) findViewById(R.id.listView);
listView.setAdapter(adapter);
getLoaderManager().initLoader(0, null, this);
}
#Override
public Loader<ArrayList<MovieItem>> onCreateLoader(int id, Bundle args) {
Log.d("Create Loader", "1");
return new MyAsyncTaskLoader(this);
}
#Override
public void onLoadFinished(Loader<ArrayList<MovieItem>> loader, ArrayList<MovieItem> data) {
Log.d("Load Finish","1");
adapter.setData(data);
}
#Override
public void onLoaderReset(Loader<ArrayList<MovieItem>> loader) {
Log.d("Load Reset","1");
adapter.setData(null);
}
#Override
public void onClick(View v) {
if (v.getId() == R.id.btn_cari){
SearchMovieTask searchMovie = new SearchMovieTask();
searchMovie.execute(edt_cari.getText().toString().trim());
}
}
private class SearchMovieTask extends AsyncTask<String,Void,String>{
#Override
protected void onPreExecute() {
super.onPreExecute();
}
#Override
protected String doInBackground(String... params) {
return null;
}
#Override
protected void onPostExecute(String s) {
super.onPostExecute(s);
}
}}
Replace your MovieAdapter to this ...!
public class MovieAdapter extends BaseAdapter implements Filterable {
private ArrayList<MovieItem> mData = new ArrayList<>();
private ArrayList<MovieItem> mSearchData = new ArrayList<>();
private ArrayList<MovieItem> categoryListOne = new ArrayList<>();
private LayoutInflater mInflater;
private Context context;
Activity activity;
ItemFilter mFilter = new ItemFilter();
private String urlConfig;
public MovieAdapter(Context context) {
this.context = context;
mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
public void setData(ArrayList<MovieItem> items) {
mData = items;
mSearchData = items;
notifyDataSetChanged();
}
public void clearData() {
mData.clear();
}
#Override
public int getItemViewType(int position) {
return 0;
}
#Override
public int getViewTypeCount() {
return 1;
}
#Override
public int getCount() {
return mData.size();
}
#Override
public MovieItem getItem(int position) {
return mData.get(position);
}
#Override
public long getItemId(int position) {
return position;
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder = null;
if (convertView == null) {
holder = new ViewHolder();
convertView = mInflater.inflate(R.layout.item_row_film, null);
holder.textViewuJudul = (TextView) convertView.findViewById(R.id.tv_judul);
holder.textViewDescription = (TextView) convertView.findViewById(R.id.tv_deskripsi);
holder.textViewRate = (TextView) convertView.findViewById(R.id.tv_rate);
holder.imgPoster = (ImageView) convertView.findViewById(R.id.img_poster);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
holder.textViewuJudul.setText(mData.get(position).getTitle());
holder.textViewDescription.setText(mData.get(position).getDescription());
holder.textViewRate.setText(mData.get(position).getRate());
Picasso.with(context).load(mData.get(position).getImgurl()).into(holder.imgPoster);
return convertView;
}
#Override
public Filter getFilter() {
return mFilter;
}
public class ItemFilter extends Filter {
#Override
protected FilterResults performFiltering(CharSequence constraint) {
constraint = constraint.toString().toLowerCase().replace(" ", "");
Log.v("DataAdapter", "constratinst : " + constraint);
FilterResults result = new FilterResults();
if (constraint.toString().length() > 0) {
ArrayList<Sticker> filteredItems =
new ArrayList<>();
for (int i = 0, l = mData.size(); i < l; i++) {
// ArrayList<HashMap<String, String>> p =
// originalList.get(i);
String p = mData.get(i).getName().toLowerCase().replace(" ", "");
if (p.toLowerCase().startsWith(String.valueOf(constraint)))
filteredItems.add(mData.get(i));
// if (p.toLowerCase().contains(constraint))
// filteredItems.add(categoryListSearch.get(i));
}
Log.v("DataAdapter", "not blank");
result.count = filteredItems.size();
result.values = filteredItems;
} else {
synchronized (this) {
result.count = categoryListOne.size();
result.values = categoryListOne;
// result.values = dataList;
// result.count = dataList.size();
}
}
return result;
}
#Override
protected void publishResults(CharSequence constraint, FilterResults results) {
// users = (List<GraphUser>) results.values;
//filteredData = (ArrayList<String>) results.values;
mData = (ArrayList<MovieItem>) results.values;
notifyDataSetChanged();
// for (int i = 0, l = mData.size(); i < l; i++)
// mSearchData.get(i);
//add(productList.get(i));
notifyDataSetInvalidated();
}
}
private class ViewHolder {
public TextView textViewuJudul;
public TextView textViewDescription;
public TextView textViewRate;
public ImageView imgPoster;
}
}
And your activity set EditText Listener to this..!
editText.addTextChangedListener(new TextWatcher() {
#Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
#Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
#Override
public void afterTextChanged(Editable editable) {
adapter.getFilter().filter(charSequence.toString());
}
});
i hope it's helpful to you ..!
Implement addTextChangedListener() on your search EditText and as the text changes filter your list data and update MovieAdapter with filtered data.
check this post on how to update custom list adapter

How to get total price of the product in listview and Display in a textview of cart?

How I can get total price of the product in listview and Display in a textview of cart and decrease the price at the product has been deleted code is given below:
public class ShoppingListAdapter extends BaseAdapter{
public static ArrayList<Product> list;
public static int position;
String idValues="";
Context context;
public static Integer total;
ViewHolder holder;
public ShoppingListAdapter(Context context,ArrayList<Product> list) {
super();
this.list = list;
this.context = context;
}
#Override
public int getCount() {
position=list.size();
return list.size();
}
#Override
public Object getItem(int position) {
return list.get(position);
}
#Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return 0;
}
static class ViewHolder {
TextView txtName;
TextView item_price;
TextView txt_thickness;
TextView txt_quantity;
Button remove;
}
#Override
public View getView(final int position, View convertView, ViewGroup parent) {
if (convertView == null) {
holder = new ViewHolder();
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.item_product_list, null);
holder.txtName = (TextView) convertView.findViewById(R.id.item_name);
holder.item_price = (TextView) convertView.findViewById(R.id.item_price);
holder.txt_thickness = (TextView) convertView.findViewById(R.id.txt_thickness);
holder.txt_quantity = (TextView) convertView.findViewById(R.id.txt_quantity);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
holder.txtName.setText(list.get(position).name);
holder.item_price.setText("Rs "+list.get(position).price);
holder.txt_thickness.setText("THICKNESS - "+list.get(position).thickness);
holder.txt_quantity.setText(list.get(position).quantity);
holder.remove= (Button) convertView.findViewById(R.id.btn_remove);
for(int i=0;i<position;i++) {
total = Integer.parseInt(list.get(i).price) * Integer.parseInt(list.get(i).quantity);
}
holder.remove.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
final String id=list.get(position).id;
StringRequest jsonObjReq = new StringRequest(Request.Method.POST,
"http://arshinfosystems.co.in/demo/AoneRubber/deletecart.php",
new Response.Listener<String>() {
#Override
public void onResponse(String response) {
}
}, new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(context, error.toString(), Toast.LENGTH_SHORT).show();
}
}) {
#Override
protected Map<String, String> getParams() {
Map<String, String> params = new HashMap<String, String>();
params.put("id", id);
return params;
}
};
jsonObjReq.setRetryPolicy(new DefaultRetryPolicy(50000,
DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
RequestQueue requestQueue = Volley.newRequestQueue(context);
requestQueue.add(jsonObjReq);
Add_to_cart.values.remove(list.get(position));
Add_to_cart.mAdapter.notifyDataSetChanged();
}
});
return convertView;
}}
public int getTotalPrice(){
int totalPrice = 0;
foreach(Product product:list){
totalPrice+ = (Integer.parseInt(prodcut.price) * Integer.parseInt(product.quantity))
}
return totalPrice;
}
Use this price as a total price.
Try This,
In Main Activity:
public void calculatePrice(ArrayList<Product> list)
{
float total=0;
for(int i=0;i<list.size();i++)
{
sub_total=sub_total+(Float.parseFloat(list_cart.get(i).price()*Float.parseFloat(list_cart.get(i).quantity());
}
TextView tv_total_amount=(TextView)view.findViewById(R.id.tv_total_amount);
tv_total_amount.setText(sub_total+"");
}
/*Call calculatePrice fuction after adapter set*/
public void setAapter()
{
ShoppingListAdapter mAdapter=new ShoppingListAdapter (context,list);
listView.setAdapter(mAdapter);
calculatePrice(list);
}
In Adapter: Call calculatePrice function after removing product
holder.remove.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
/*After call webservice remove product from list*/
list.remove(position)
notifyDataSetChanged();
if (context instanceof MainActivity) {
((MainActivity) context).calculatePrice(list);
}
}
});

Listview with Checkbox,Textview and button not working correctly in android?

I am creating an android app the UI of my application is below given.
On clicking of submit button, I need the selected check box, value and id textview
example size is not checked, cc(radio button) is checked.
records are populated dynamically in list view, but I am not able to make it work.
Checkbox_ProducoptionActivity.java
public class MainActivity extends Activity implements OnItemClickListener {
ListView listview;
ArrayList<HashMap<String, String>> list_kategori ;
ProgressDialog pd;
ArrayAdapter<Model_checkbox> adapter;
List<String> idprdoptins = new ArrayList<String>();
List<Model_checkbox> nameprdoptn = new ArrayList<Model_checkbox>();
List<Model_checkbox> list = new ArrayList<Model_checkbox>();
Button btn_checkbox;
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.checkboxproduct_option);
listview = (ListView)findViewById(R.id.list);
btn_checkbox = (Button)findViewById(R.id.btn_productoption);
// TODO Auto-generated method stub
String id =CheckLogin();
if (id!=""){
loadproductoption(id);
}
btn_checkbox.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
for (Model_checkbox m : list) {
Log.i("Stack1", m.toString());
}
Log.d("Stack1",String.valueOf(Model_checkbox.class));
Toast.makeText(getApplicationContext(), "ada",Toast.LENGTH_LONG).show();
}
});
}
public void loadproductoption(String id) {
listproduct task= new listproduct();
task.execute(id);
}
private class listproduct extends AsyncTask<String, Void, String>{
protected void onPreExecute(){
pd = new ProgressDialog(Checkbox_ProducoptionActivity.this);
pd.setMessage("Please wait..");
pd.setCancelable(false);
pd.show();
}
#Override
protected String doInBackground(String... params) {
// TODO Auto-generated method stub
JSONObject jsonResult = HttpClientCustom.getRequest(Konfigurasi.strUrl+"api-v1/proop?id_user="+ params[0]);
return jsonResult.toString();
}
protected void onPostExecute(String result){
JSONObject jsonResponse=null;
JSONArray jObject=null;
list_kategori = new ArrayList<HashMap<String, String>>();
try {
jsonResponse = new JSONObject(new String(result));
if(jsonResponse.getString("status").equals("SUCCESS")) {
if (!jsonResponse.getString("total").equals("0")){
jObject = jsonResponse.getJSONArray("resultset");
for (int i = 0; i < jObject.length(); i++) {
HashMap<String, String> map = new HashMap<String, String>();
map.put("idprd", jObject.getJSONObject(i).getString("id"));
map.put("id_user", jObject.getJSONObject(i).getString("id_user"));
map.put("namepd", jObject.getJSONObject(i).getString("name"));
setListnama(jObject.getJSONObject(i).getString("name"));
list_kategori.add(map);
}
adapter = new Adapter_Checkboxproductoption(Checkbox_ProducoptionActivity.this, getModel());
listview.setAdapter(adapter);
}
pd.dismiss();
} else if (jsonResponse.getString("status").equals("FAILED")) {
pd.dismiss();
}
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
pd.dismiss();
}
private List<Model_checkbox> getModel() {
return nameprdoptn;
}
public void setListnama(String name) {
nameprdoptn.add(new Model_checkbox(name));
}
}
Model checkbox.java
// public class My modele {
public class Model_checkbox {
private String name;
private boolean selected;
//private boolean isCcOrIsTo;
public Model_checkbox(String name) {
this.name = name;
}
public String getName() {
return name;
}
public boolean isSelected() {
return selected;
}
public void setSelected(boolean selected) {
this.selected = selected;
}
#Override
public String toString() {
String selectedString = selected ? "selected" : "not selected";
// String value = isCcOrIsTo ? "CC" : "To";
return name+" -> "+selectedString+ " with value ";
}
}
MyAdapter.java
// public class MyAdapter extends ArrayAdapter {
class ViewHolder {
protected TextView text;
protected CheckBox checkbox;
}
public class Adapter_Checkboxproductoption extends ArrayAdapter<Model_checkbox> {
private final List<Model_checkbox> list;
private final Activity context;
boolean checkAll_flag = false;
boolean checkItem_flag = false;
public Adapter_Checkboxproductoption(Activity context, List<Model_checkbox> list) {
super(context, R.layout.list_checkbox, list);
this.context = context;
this.list = list;
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder viewHolder = null;
if (convertView == null) {
LayoutInflater inflator = context.getLayoutInflater();
convertView = inflator.inflate(R.layout.list_checkbox, null);
viewHolder = new ViewHolder();
viewHolder.text = (TextView) convertView.findViewById(R.id.rowTextView);
viewHolder.checkbox = (CheckBox) convertView.findViewById(R.id.CheckBox01);
viewHolder.checkbox.setTag(position);
convertView.setTag(viewHolder);
} else {
viewHolder = (ViewHolder) convertView.getTag();
}
viewHolder.text.setText(list.get(position).getName());
viewHolder.checkbox.setChecked(list.get(position).isSelected());
viewHolder.checkbox.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
CheckBox checkbox = (CheckBox) v;
int getPosition = (Integer) checkbox.getTag();
list.get(getPosition).setSelected(checkbox.isChecked());
}
});
return convertView;
}
}
can't work in "Checkbox_ProducoptionActivity.java"
for (Model_checkbox m : list) {
Log.i("Stack1", m.toString());
Can any body help me in getting value and id of selected check box?
All you need to do is get/set the value of checked item in your adapter this way, I did in Cursor adapter you can update below code as per your need.
public class CursorAdapterList extends CursorAdapter {
private LayoutInflater inflater = null;
private DBAdapter db = null;
private Context ctx = null;
public CursorAdapterList(Context context, Cursor c, DBAdapter database) {
super(context, c);
ctx = context;
db = database;
inflater = LayoutInflater.from(context);
}
#Override
public void bindView(View view, Context context, Cursor cursor) {
TextView tv = (TextView) view.findViewById(R.id.txtGameNameInList);
CheckBox favBox = (CheckBox) view.findViewById(R.id.favbuttonInList);
tv.setText(cursor.getString(1));
//here I am getting value of already checked boxes from db
String flag = cursor.getString(3);
if (flag.equals("true")) {
favBox.setChecked(true);
} else {
favBox.setChecked(false);
}
favBox.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
LinearLayout parentView = (LinearLayout) v.getParent();
TextView clickedText = (TextView) parentView
.findViewById(R.id.txtGameNameInList);
//here you can get the Item value what your selcted in your list
String name = clickedText.getText().toString();
if (((CheckBox) v).isChecked()) {
Toast.makeText(ctx, name + " is Marked as Favorite Game!!",
Toast.LENGTH_SHORT).show();
//below method will store selected item value in db
db.markAsFavorite(name, "true");
} else {
db.markAsFavorite(name, "false");
}
}
});
}
#Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
return inflater.inflate(R.layout.list_row_custom, parent, false);
}
}
For my activity
public class Checkbox_ProducoptionActivity<country> extends Activity {
ListView list;
static Context mContext;
Button btnSave;
List<String> val = new ArrayList<String>();
ArrayList<HashMap<String, String>> list_kategori ;
ArrayList<String> stock_list = new ArrayList<String>();
ArrayList<String> stock2_list = new ArrayList<String>();
ProgressDialog pd;
EfficientAdapter adapter;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.checkboxproduct_option);
list = (ListView) findViewById(R.id.ListView01);
btnSave = (Button)findViewById(R.id.btnSave);
mContext = this;
final String id =CheckLogin();
if (id!=""){
loadproductoption(id);
}
btnSave.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
SharedPreferences val_shared = getSharedPreferences("CHECKBOX_SHARED", MODE_WORLD_WRITEABLE);
SharedPreferences.Editor cleareditor=val_shared.edit();
cleareditor.clear();
cleareditor.commit();
for (int i = 0; i <list.getCount() ; i++) {
View vListSortOrder;
vListSortOrder=list.getChildAt(i);
try{
TextView textval= (TextView)vListSortOrder.findViewById(R.id.TextView01);
CheckBox ckc=(CheckBox)vListSortOrder.findViewById(R.id.chkbox1);
EditText edit=(EditText)vListSortOrder.findViewById(R.id.txtbox);
if (ckc.isChecked()){
edit.getText().toString();
String temp1 = textval.getText().toString();
Toast.makeText(getApplicationContext(), "fuck"+textval.getText().toString(), Toast.LENGTH_LONG).show();
val.add(temp1);
}
}catch (Exception e) {
// TODO: handle exception
}
}
SharedPreferences customer_ident = getSharedPreferences("CHECKBOX_SHARED", MODE_WORLD_WRITEABLE);
SharedPreferences.Editor editor=customer_ident.edit();
editor.putString("valuecheck", val.toString());
editor.commit();
// Toast.makeText(getApplicationContext(), "ada "+val, Toast.LENGTH_LONG).show();
Intent prdmenuact = new Intent(getApplicationContext(),CreateManageProductActivity.class);
prdmenuact.putExtra("idaction", "1");
startActivity(prdmenuact);
finish();
}
});
}
public void loadproductoption(String id) {
listproduct task= new listproduct();
task.execute(id);
}
private class listproduct extends AsyncTask<String, Void, String>{
protected void onPreExecute(){
pd = new ProgressDialog(Checkbox_ProducoptionActivity.this);
pd.setMessage("Please wait..");
pd.setCancelable(false);
pd.show();
}
#Override
protected String doInBackground(String... params) {
// TODO Auto-generated method stub
JSONObject jsonResult = HttpClientCustom.getRequest(Konfigurasi.strUrl+"api-v1/proop?id_user="+ params[0]);
return jsonResult.toString();
}
protected void onPostExecute(String result){
JSONObject jsonResponse=null;
JSONArray jObject=null;
list_kategori = new ArrayList<HashMap<String, String>>();
try {
jsonResponse = new JSONObject(new String(result));
if(jsonResponse.getString("status").equals("SUCCESS")) {
if (!jsonResponse.getString("total").equals("0")){
jObject = jsonResponse.getJSONArray("resultset");
for (int i = 0; i < jObject.length(); i++) {
HashMap<String, String> map = new HashMap<String, String>();
map.put("idprd", jObject.getJSONObject(i).getString("id"));
map.put("id_user", jObject.getJSONObject(i).getString("id_user"));
map.put("namepd", jObject.getJSONObject(i).getString("name"));
list_kategori.add(map);
}
adapter = new EfficientAdapter(Checkbox_ProducoptionActivity.this,list_kategori );
list.setAdapter(adapter);
}
pd.dismiss();
} else if (jsonResponse.getString("status").equals("FAILED")) {
pd.dismiss();
}
} catch (JSONException e) {
//TODO Auto-generated catch block
e.printStackTrace();
}
pd.dismiss();
}
}
my adpater
public class EfficientAdapter extends BaseAdapter {
private Activity activity;
private ArrayList<HashMap<String, String>> data;
private LayoutInflater inflater=null;
public ImageLoader imageLoader;
String priceprd ;
public EfficientAdapter (Activity a, ArrayList<HashMap<String, String>> d) {
activity = a;
data=d;
inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
imageLoader=new ImageLoader(activity.getApplicationContext());
}
public EfficientAdapter(Runnable runnable,
ArrayList<HashMap<String, String>> list_kategori) {
// TODO Auto-generated constructor stub
}
public int getCount() {
//Log.d("country",String.valueOf(data.size()));
return data.size();
}
public Object getItem(int position) {
return position;
}
public long getItemId(int position) {
return position;
}
public View getView(int position, View convertView, ViewGroup parent) {
final ViewHolder holder;
if (convertView == null) {
convertView = inflater.inflate(R.layout.list_checkbox, parent,
false);
holder = new ViewHolder();
holder.text = (TextView) convertView.findViewById(R.id.TextView01);
holder.text2 = (TextView) convertView.findViewById(R.id.TextView02);
holder.txt = (EditText) convertView.findViewById(R.id.txtbox);
holder.cbox = (CheckBox) convertView.findViewById(R.id.chkbox1);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
holder.text.setText( data.get(position).get("idprd"));
holder.text2.setText(data.get(position).get("namepd"));
holder.txt.setText("");
holder.cbox.setChecked(false);
return convertView;
}
public class ViewHolder {
TextView text;
TextView text2;
EditText txt;
CheckBox cbox;
}
}
public String[] convert(List<String[]> list1) {
// TODO Auto-generated method stub
return null;
}
adapter to be replaced
and the model removed
so to check the value of just using ischecked
for (int i = 0; i <list.getCount() ; i++) {
View vListSortOrder;
vListSortOrder=list.getChildAt(i);
try{
TextView textval= (TextView)vListSortOrder.findViewById(R.id.TextView01);
CheckBox ckc=(CheckBox)vListSortOrder.findViewById(R.id.chkbox1);
EditText edit=(EditText)vListSortOrder.findViewById(R.id.txtbox);
if (ckc.isChecked()){
edit.getText().toString();
String temp1 = textval.getText().toString();
Toast.makeText(getApplicationContext(), "fuck"+textval.getText().toString(), Toast.LENGTH_LONG).show();
val.add(temp1);
}
}catch (Exception e) {
// TODO: handle exception
}
}
and successful

Categories

Resources