android-viewholder

Edittext values in listview changes to default on screen timeout

拜拜、爱过 提交于 2019-12-04 21:51:18
I have a listview with edittext widgets inside each row. I use a viewholder inside my custom adapter to keep track of all the views. But my problem is that when i input a value inside my edittext , pause until my screen times out, when you unlock the phone while still in the same activity ,the default edittext value is refilled, overwriting my edits. I followed this suggestion here (when listview scroll that time edittext set default value) considering that maybe i am not using the viewholder right but still facing the same issue. It's like getView() keeps getting called, completely redrawing

Switch between RecyclerView layouts when click on AlertDialog item list

时光总嘲笑我的痴心妄想 提交于 2019-12-04 10:14:26
I have three different layouts cardsListLayout , titleLayout , cardMagazineLayout and there may be more in the future, which used as a views on onCreateViewHolder method. I want to switch between views in onCreateViewHolder method so when user choose from AlertDialog list this onOptionsItemSelected in MainActivity Where there is menu Item "change the layout" so that when the user presses it it appears AlertDialog list @Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == R.id.change_layout) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder

Is there a way to use a ViewStub inside a RecyclerView?

核能气质少年 提交于 2019-12-04 09:17:01
i'm new to android, I've been working on a project, and in my news feeds page, I'm trying to include a modular feed RecyclerView, which shows a question with different answer forms, varrying according to the Question type. The way I was doing it so far was by using the include and turning the forms visible when needed. recently since i added more modules, the app started to slowdown segnificantly, so i'm trying to implement ViewStubs. This is my RecyclerView adapter: public class ReQuestionAdapter extends RecyclerView.Adapter<FeedItem> { private ArrayList<Question> myQuestions; public

Issue with ViewHolder selection

别来无恙 提交于 2019-12-04 06:56:23
问题 I am working in an app in which I handle a ListView which is composite with ViewHolder . In this ViewHolder , I have a CheckBox . Here is my code: private class SettingsArrayAdapter extends ArrayAdapter<Object> { Context context; ArrayList<Object> values; RowSettingsViewHolder vh = null; BigRowSettingsViewHolder bvh = null; @Override public int getItemViewType(int position) { if (values.get(position) instanceof RowContent) { return SMALL_ROW_DESIGN; } else return BIG_ROW_DESIGN; // return

Checkedtextview check/uncheck after scroll Listview

六月ゝ 毕业季﹏ 提交于 2019-12-04 05:12:09
问题 I'm developing checkedtextview in listvew using viewHolder and getview. To populate check/uncheck status binding from database is running well. But, if I check item and then scroll listview, it will back to uncheck. here is my customAdapter code. public class CustomAdapter extends ArrayAdapter<Model> { private Activity activity; int id; String autoid; ArrayList<Model> items; DatabaseHelper dbhelper = new DatabaseHelper(getContext()); public CustomAdapter(Activity context, int resource,

Where should I place setOnClickListener in a RecyclerView Adapter

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-04 03:45:46
In tutorials on internet where they setOnClickListener in Adapter of RecyclerView they define it in two ways : either inside ViewHolder or inside BindViewHolder. My Question is which one is a better approach, Please recommend any another approach if available 1) inside ViewHolder: public static class ViewHolder extends RecyclerView.ViewHolder { public ViewHolder(View itemView) { super(itemView); tvSrc = (TextView) itemView.findViewById(R.id.tvSrc); itemView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Toast.makeText(v.getContext(), "inside viewholder

Android: how can I insert a RecyclerView inside CardView?

可紊 提交于 2019-12-03 18:49:38
问题 The activity I am talking about must show a RecyclerView populated by CardViews as items. My goal is to show in every CardView a RecyclerView in its turn. Here my Activity's basic 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=".ConjActivity" > <android.support.v7.widget.RecyclerView android

RecyclerView - callback when view is no longer visible

為{幸葍}努か 提交于 2019-12-03 18:38:28
问题 I have a RecyclerView with its Adapter and LayoutManager. Adapter has approximate 15 different ViewHolders. One of them contain WebView which loads external contents (99% of them are videos outside of YouTube). The problem comes when any View of Adapter gets out of the screen - video in WebView keeps playing and sound is playing. Still, that's acceptable for me. The key problem starts when I move to another Activity. The sound of the video is still present. Is there any way RecyclerView could

RecyclerView - get Position inside Activity rather than RecyclerViewAdapter

爷,独闯天下 提交于 2019-12-03 17:24:47
It is my third day now dealing with the handling of my view clicks. I originally was using ListView , then I switched to RecyclerView . I have added android:onclick elements to every control on my row_layout and I am handling them in my MainActivity like this: public void MyMethod(View view) {} In my old ListView implementation, I have done setTag(position) to be able to get it in MyMethod by doing this inside it: Integer.parseInt(view.getTag().toString()) This worked nicely without problems. Though now I am dealing with RecyclerView and being forced to use the ViewHolder , which does not

Why in ViewHolder pattern should the ViewHolder class be static?

允我心安 提交于 2019-12-03 14:50:55
问题 I am just trying to have a better understanding of the following pattern I regularly use to optimize ListView My readings only pointed me to the fact that a static inner class is treated as top level class. What is the benefit of such a thing compared to a member class (non static)? @Override public View getView(int position, View convertView, ViewGroup parent) { Comment comment = getItem(position); ViewHolder holder; if (convertView == null){ holder = new ViewHolder(); convertView =