Search in sources :

Example 51 with Button

use of android.widget.Button in project platform_frameworks_base by android.

the class VectorDrawablePerformance method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ScrollView scrollView = new ScrollView(this);
    GridLayout container = new GridLayout(this);
    scrollView.addView(container);
    container.setColumnCount(4);
    Resources res = this.getResources();
    container.setBackgroundColor(0xFF888888);
    VectorDrawable[] d = new VectorDrawable[icon.length];
    long time = android.os.SystemClock.elapsedRealtimeNanos();
    for (int i = 0; i < icon.length; i++) {
        d[i] = create(res, icon[i]);
    }
    time = android.os.SystemClock.elapsedRealtimeNanos() - time;
    TextView t = new TextView(this);
    DecimalFormat df = new DecimalFormat("#.##");
    t.setText("avgL=" + df.format(time / (icon.length * 1000000.)) + " ms");
    container.addView(t);
    time = android.os.SystemClock.elapsedRealtimeNanos();
    for (int i = 0; i < icon.length; i++) {
        Button button = new Button(this);
        button.setWidth(200);
        button.setBackgroundResource(icon[i]);
        container.addView(button);
    }
    setContentView(scrollView);
    time = android.os.SystemClock.elapsedRealtimeNanos() - time;
    t = new TextView(this);
    t.setText("avgS=" + df.format(time / (icon.length * 1000000.)) + " ms");
    container.addView(t);
}
Also used : GridLayout(android.widget.GridLayout) ScrollView(android.widget.ScrollView) Button(android.widget.Button) DecimalFormat(java.text.DecimalFormat) TextView(android.widget.TextView) Resources(android.content.res.Resources) VectorDrawable(android.graphics.drawable.VectorDrawable)

Example 52 with Button

use of android.widget.Button in project platform_frameworks_base by android.

the class AnimatedVectorDrawableDupPerf method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ScrollView scrollView = new ScrollView(this);
    GridLayout container = new GridLayout(this);
    scrollView.addView(container);
    container.setColumnCount(5);
    Resources res = this.getResources();
    container.setBackgroundColor(0xFF888888);
    AnimatedVectorDrawable[] d = new AnimatedVectorDrawable[icon.length];
    long time = android.os.SystemClock.elapsedRealtimeNanos();
    for (int i = 0; i < icon.length; i++) {
        d[i] = create(res, icon[i]);
    }
    time = android.os.SystemClock.elapsedRealtimeNanos() - time;
    TextView t = new TextView(this);
    DecimalFormat df = new DecimalFormat("#.##");
    t.setText("avgL=" + df.format(time / (icon.length * 1000000.)) + " ms");
    container.addView(t);
    time = android.os.SystemClock.elapsedRealtimeNanos();
    for (int i = 0; i < icon.length; i++) {
        Button button = new Button(this);
        button.setWidth(200);
        button.setBackgroundResource(icon[i]);
        container.addView(button);
    }
    setContentView(scrollView);
    time = android.os.SystemClock.elapsedRealtimeNanos() - time;
    t = new TextView(this);
    t.setText("avgS=" + df.format(time / (icon.length * 1000000.)) + " ms");
    container.addView(t);
}
Also used : GridLayout(android.widget.GridLayout) ScrollView(android.widget.ScrollView) Button(android.widget.Button) DecimalFormat(java.text.DecimalFormat) TextView(android.widget.TextView) Resources(android.content.res.Resources) AnimatedVectorDrawable(android.graphics.drawable.AnimatedVectorDrawable)

Example 53 with Button

use of android.widget.Button in project platform_frameworks_base by android.

the class AnimatedVectorDrawableTest method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    final int[] layerTypes = { View.LAYER_TYPE_SOFTWARE, View.LAYER_TYPE_HARDWARE };
    final boolean[] forceOnUi = { false, true };
    super.onCreate(savedInstanceState);
    ScrollView scrollView = new ScrollView(this);
    GridLayout container = new GridLayout(this);
    scrollView.addView(container);
    container.setColumnCount(layerTypes.length * forceOnUi.length);
    for (int j = 0; j < layerTypes.length; j++) {
        for (int k = 0; k < forceOnUi.length; k++) {
            TextView textView = new TextView(this);
            String category = "Layer:" + (layerTypes[j] == View.LAYER_TYPE_SOFTWARE ? "SW" : "HW") + (forceOnUi[k] == true ? ",forceUI" : "");
            textView.setText(category);
            container.addView(textView);
        }
    }
    for (int i = 0; i < icon.length; i++) {
        for (int j = 0; j < layerTypes.length; j++) {
            for (int k = 0; k < forceOnUi.length; k++) {
                Button button = new Button(this);
                button.setWidth(300);
                button.setHeight(300);
                button.setLayerType(layerTypes[j], null);
                button.setBackgroundResource(icon[i]);
                AnimatedVectorDrawable d = (AnimatedVectorDrawable) button.getBackground();
                if (forceOnUi[k] == true) {
                    d.forceAnimationOnUI();
                }
                d.registerAnimationCallback(new Animatable2.AnimationCallback() {

                    @Override
                    public void onAnimationStart(Drawable drawable) {
                        Log.v(LOGCAT, "Animator start");
                    }

                    @Override
                    public void onAnimationEnd(Drawable drawable) {
                        Log.v(LOGCAT, "Animator end");
                    }
                });
                container.addView(button);
                button.setOnClickListener(this);
            }
        }
    }
    setContentView(scrollView);
}
Also used : AnimatedVectorDrawable(android.graphics.drawable.AnimatedVectorDrawable) Drawable(android.graphics.drawable.Drawable) AnimatedVectorDrawable(android.graphics.drawable.AnimatedVectorDrawable) Animatable2(android.graphics.drawable.Animatable2) GridLayout(android.widget.GridLayout) ScrollView(android.widget.ScrollView) Button(android.widget.Button) TextView(android.widget.TextView)

Example 54 with Button

use of android.widget.Button in project platform_frameworks_base by android.

the class BaseErrorDialog method setEnabled.

private void setEnabled(boolean enabled) {
    Button b = (Button) findViewById(R.id.button1);
    if (b != null) {
        b.setEnabled(enabled);
    }
    b = (Button) findViewById(R.id.button2);
    if (b != null) {
        b.setEnabled(enabled);
    }
    b = (Button) findViewById(R.id.button3);
    if (b != null) {
        b.setEnabled(enabled);
    }
}
Also used : Button(android.widget.Button)

Example 55 with Button

use of android.widget.Button in project VideoRecorder by qdrzwd.

the class Util method showDialog.

/**
	 * 公共弹窗
	 * 
	 * @param context
	 *            :Context 传入当前调用该方法的activity实例
	 * @param msg
	 *            :String 要显示的显示文字
	 * @param type
	 *            :int 显示类型1:仅为确定,2:有“确定”、“取消”两个操作
	 * @param handler
	 *            :Handler 传入的需要回调的handler信息,可作为回调方法是用,msg.what = 1时为操作完成状态符
	 */
public static void showDialog(Context context, String title, String content, int type, final Handler handler) {
    final Dialog dialog = new Dialog(context, R.style.Dialog_loading);
    dialog.setCancelable(true);
    // 设置像是内容模板
    LayoutInflater inflater = LayoutInflater.from(context);
    View view = inflater.inflate(R.layout.global_dialog_tpl, null);
    Button confirmButton = (Button) view.findViewById(// 确认
    R.id.setting_account_bind_confirm);
    Button cancelButton = (Button) view.findViewById(// 取消
    R.id.setting_account_bind_cancel);
    TextView dialogTitle = (TextView) view.findViewById(// 标题
    R.id.global_dialog_title);
    // 中竖线
    View lineHoriCenter = view.findViewById(R.id.line_hori_center);
    // 默认隐藏取消按钮
    confirmButton.setVisibility(View.GONE);
    lineHoriCenter.setVisibility(View.GONE);
    TextView textView = (TextView) view.findViewById(R.id.setting_account_bind_text);
    // 设置对话框的宽度
    Window dialogWindow = dialog.getWindow();
    WindowManager.LayoutParams lp = dialogWindow.getAttributes();
    lp.width = (int) (context.getResources().getDisplayMetrics().density * 288);
    dialogWindow.setAttributes(lp);
    // 设置显示类型
    if (type != 1 && type != 2) {
        type = 1;
    }
    // 设置标题
    dialogTitle.setText(title);
    // 设置提示内容
    textView.setText(content);
    // 确认按钮操作
    if (type == 1 || type == 2) {
        confirmButton.setVisibility(View.VISIBLE);
        confirmButton.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                if (handler != null) {
                    Message msg = handler.obtainMessage();
                    msg.what = 1;
                    handler.sendMessage(msg);
                }
                dialog.dismiss();
            }
        });
    }
    // 取消按钮事件
    if (type == 2) {
        cancelButton.setVisibility(View.VISIBLE);
        lineHoriCenter.setVisibility(View.VISIBLE);
        cancelButton.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                if (handler != null) {
                    Message msg = handler.obtainMessage();
                    msg.what = 0;
                    handler.sendMessage(msg);
                }
                dialog.dismiss();
            }
        });
    }
    dialog.addContentView(view, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    // 点击返回键关闭
    dialog.setCancelable(true);
    // 点击外部关闭
    dialog.setCanceledOnTouchOutside(true);
    dialog.show();
}
Also used : Window(android.view.Window) LayoutParams(android.widget.LinearLayout.LayoutParams) Message(android.os.Message) Button(android.widget.Button) Dialog(android.app.Dialog) LayoutInflater(android.view.LayoutInflater) OnClickListener(android.view.View.OnClickListener) TextView(android.widget.TextView) View(android.view.View) TextView(android.widget.TextView) WindowManager(android.view.WindowManager)

Aggregations

Button (android.widget.Button)1477 View (android.view.View)909 TextView (android.widget.TextView)609 OnClickListener (android.view.View.OnClickListener)275 Intent (android.content.Intent)200 LinearLayout (android.widget.LinearLayout)189 ImageView (android.widget.ImageView)146 EditText (android.widget.EditText)126 ListView (android.widget.ListView)112 AdapterView (android.widget.AdapterView)76 ViewGroup (android.view.ViewGroup)65 LayoutInflater (android.view.LayoutInflater)56 CompoundButton (android.widget.CompoundButton)53 ScrollView (android.widget.ScrollView)53 Test (org.junit.Test)51 Bundle (android.os.Bundle)49 CheckBox (android.widget.CheckBox)48 FrameLayout (android.widget.FrameLayout)47 AlertDialog (android.app.AlertDialog)45 ImageButton (android.widget.ImageButton)45