Advertisement
Guest User

Untitled

a guest
Mar 18th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.47 KB | None | 0 0
  1. LinearLayout ll = new LinearLayout(mContext);
  2.         ll.setOrientation(LinearLayout.VERTICAL);
  3.         ll.setBackgroundColor(Color.parseColor("#DDDDDD"));
  4.  
  5.         TextView tv = new TextView(mContext);
  6.         tv.setText(R.string.str_select_color);
  7.         tv.setGravity(Gravity.CENTER_HORIZONTAL);
  8.         tv.setBackgroundColor(Color.parseColor("#DDDDDD"));
  9.         tv.setWidth(240);
  10. //        tv.setHeight(0);
  11.         tv.setPadding(4, 0, 4, 10);
  12.         ll.addView(tv);
  13.  
  14.         Drawable drawableCheckboxOn = ContextCompat.getDrawable(mContext, R.drawable.ic_checkbox_on_background);
  15.         Drawable drawableCheckboxOff = ContextCompat.getDrawable(mContext, R.drawable.ic_checkbox_off_background);
  16.  
  17.         Button b1 = new Button(mContext);
  18.         b1.setText(R.string.str_theme_one);
  19. //        b1.setGravity(Gravity.CENTER);
  20.         b1.setCompoundDrawablesWithIntrinsicBounds(drawableCheckboxOff, null, null, null);
  21. //        b1.setBackgroundColor(Color.parseColor("#757575"));
  22.         b1.setBackgroundResource(R.drawable.rounded_btn_theme_one);
  23. //        b1.setForeground(new ColorDrawable(ContextCompat.getColor(mContext, R.color.other_overlay))); // Color.parseColor("#757575")
  24.         b1.setOnClickListener(new View.OnClickListener() {
  25.             public void onClick(View v) {
  26.                 SoundPoolPlay.playSoundPool("touch_one");
  27.                 if (editor != null) {
  28.                     Toast.makeText(v.getContext(), R.string.theme_changed, Toast.LENGTH_SHORT).show();
  29.                     editor.putString("theme", "theme1").apply();
  30.                     isApplyTheme = true;
  31.                 }
  32.                 dialog.dismiss();
  33.             }
  34.         });
  35.         ll.addView(b1);
  36.  
  37.         Button b2 = new Button(mContext);
  38.         b2.setText(R.string.str_theme_two);
  39. //        b2.setGravity(Gravity.CENTER);
  40.         b2.setCompoundDrawablesWithIntrinsicBounds(drawableCheckboxOff, null, null, null);
  41.         b2.setBackgroundColor(Color.parseColor("#66808080"));
  42.         b2.setOnClickListener(new View.OnClickListener() {
  43.             public void onClick(View v) {
  44.                 SoundPoolPlay.playSoundPool("touch_one");
  45.                 if (editor != null) {
  46.                     Toast.makeText(v.getContext(), R.string.theme_changed, Toast.LENGTH_SHORT).show();
  47.                     editor.putString("theme", "theme2").apply();
  48.                     isApplyTheme = true;
  49.                 }
  50.                 dialog.dismiss();
  51.             }
  52.         });
  53.         ll.addView(b2);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement