Search in sources :

Example 1 with LayoutParams

use of android.support.design.widget.AppBarLayout.LayoutParams in project android2 by aqi00.

the class ScrollFlagActivity method initFlagSpinner.

// 初始化滚动标志的下拉框
private void initFlagSpinner() {
    ArrayAdapter<String> flagAdapter = new ArrayAdapter<String>(this, R.layout.item_select, descArray);
    flagAdapter.setDropDownViewResource(R.layout.item_dropdown);
    Spinner sp_style = findViewById(R.id.sp_flag);
    sp_style.setPrompt("请选择滚动标志");
    sp_style.setAdapter(flagAdapter);
    // 设置下拉框列表的选择监听器
    sp_style.setOnItemSelectedListener(new OnItemSelectedListener() {

        public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
            // 获取可折叠布局的布局参数
            LayoutParams params = (LayoutParams) ctl_title.getLayoutParams();
            // 设置布局参数中的滚动标志位
            params.setScrollFlags(flagArray[arg2]);
            // 设置可折叠布局的布局参数。注意:第三种滚动标志一定要调用setLayoutParams
            ctl_title.setLayoutParams(params);
        }

        public void onNothingSelected(AdapterView<?> arg0) {
        }
    });
    sp_style.setSelection(0);
}
Also used : LayoutParams(android.support.design.widget.AppBarLayout.LayoutParams) Spinner(android.widget.Spinner) OnItemSelectedListener(android.widget.AdapterView.OnItemSelectedListener) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) AdapterView(android.widget.AdapterView) ArrayAdapter(android.widget.ArrayAdapter)

Aggregations

LayoutParams (android.support.design.widget.AppBarLayout.LayoutParams)1 RecyclerView (android.support.v7.widget.RecyclerView)1 View (android.view.View)1 AdapterView (android.widget.AdapterView)1 OnItemSelectedListener (android.widget.AdapterView.OnItemSelectedListener)1 ArrayAdapter (android.widget.ArrayAdapter)1 Spinner (android.widget.Spinner)1