Advertisement
Guest User

Untitled

a guest
Dec 13th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.03 KB | None | 0 0
  1. package app.listazakupow;
  2. import android.annotation.SuppressLint;
  3. import android.content.Intent;
  4. import android.os.Bundle;
  5. import android.support.v7.app.AppCompatActivity;
  6. import android.support.v7.widget.RecyclerView;
  7. import android.widget.TextView;
  8.  
  9.  
  10. import java.util.ArrayList;
  11.  
  12. public class FinalListActivity extends AppCompatActivity {
  13.     private ArrayList<String> finalListArrayList;
  14.     private RecyclerView recyclerView;
  15.     private TextView textView1, textView2, textView3;
  16.     private MyAdapter myAdapter;
  17.     @SuppressLint("WrongViewCast")
  18.     @Override
  19.     protected void onCreate(Bundle savedInstanceState) {
  20.         super.onCreate(savedInstanceState);
  21.         setContentView(R.layout.finallist_layout);
  22.         Intent intent = getIntent();
  23.         finalListArrayList = intent.getStringArrayListExtra("productList");
  24.         recyclerView = (RecyclerView) findViewById(R.id.recycler_view1);
  25.  
  26.         //CustomAdapter adapter = new CustomAdapter<>(this, android.R.layout.simple_dropdown_item_1line, finalListArrayList);
  27.         myAdapter = new MyAdapter(finalListArrayList);
  28.         recyclerView.setAdapter(myAdapter);
  29.         myAdapter.notifyDataSetChanged();
  30.         textView1 = (TextView) findViewById(R.id.textView1);
  31.         textView2 = (TextView) findViewById(R.id.textView2);
  32.         textView3 = (TextView) findViewById(R.id.textView3);
  33.  
  34.         textView1.setText("Amount of products: " + finalListArrayList.size());
  35.     }
  36.  
  37. //    private class CustomAdapter<String> extends ArrayAdapter<String>{
  38. //        LinearLayout linearLayout;
  39. //        TextView final_list_TextView1;
  40. //        CheckBox checkBox;
  41. //        private CustomAdapter(Context context, int resource, ArrayList<String> object){
  42. //            super(context,resource,object);
  43. //        }
  44. //        @Override
  45. //        public View getView(final int position, View view, final ViewGroup parentView){
  46. //            if(view==null) {
  47. //                view = LayoutInflater.from(getContext()).inflate(R.layout.finallist_list_layout, parentView, false);
  48. //            }
  49. //            linearLayout = (LinearLayout) view.findViewById(R.id.linearLayout1);
  50. //            final_list_TextView1 = (TextView) view.findViewById(R.id.final_list_TextView1);
  51. //            final_list_TextView1.setText(finalListArrayList.get(position));
  52. //            checkBox = (CheckBox) view.findViewById(R.id.checkBox1);
  53. //            checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
  54. //                @Override
  55. //                public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
  56. //                    if(isChecked){
  57. //                        parentView.getChildAt(position).setBackgroundColor(Color.rgb(0,225,0));
  58. //                        notifyDataSetChanged();
  59. //                    }
  60. //                    else{
  61. //
  62. //                        parentView.getChildAt(position).setBackgroundColor(Color.WHITE);
  63. //                    }
  64. //                }
  65. //            });
  66. //            return view;
  67. //        }
  68. //    }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement