11 package com.freerdp.freerdpcore.utils;
13 import android.content.Context;
14 import android.preference.Preference;
15 import android.util.AttributeSet;
16 import android.view.View;
17 import android.view.View.OnClickListener;
18 import android.view.ViewGroup;
19 import android.widget.Button;
20 import android.widget.LinearLayout;
22 import com.freerdp.freerdpcore.R;
27 private OnClickListener buttonOnClickListener;
28 private String buttonText;
29 private Button button;
39 super(context, attrs);
45 super(context, attrs, defStyle);
51 setLayoutResource(R.layout.button_preference);
54 buttonOnClickListener =
null;
57 @Override
public View getView(View convertView, ViewGroup parent)
59 View v = super.getView(convertView, parent);
60 button = (Button)v.findViewById(R.id.preference_button);
61 if (buttonText !=
null)
62 button.setText(buttonText);
63 if (buttonOnClickListener !=
null)
64 button.setOnClickListener(buttonOnClickListener);
69 LinearLayout widgetFrameView = ((LinearLayout)v.findViewById(android.R.id.widget_frame));
70 widgetFrameView.setVisibility(View.VISIBLE);
75 public void setButtonText(
int resId)
77 buttonText = getContext().getResources().getString(resId);
79 button.setText(buttonText);
82 public void setButtonText(String text)
89 public void setButtonOnClickListener(OnClickListener listener)
92 button.setOnClickListener(listener);
94 buttonOnClickListener = listener;