|
| 1 | +package com.clock.systemui.activity.bs; |
| 2 | + |
| 3 | +import android.support.design.widget.BottomSheetDialog; |
| 4 | +import android.support.v7.app.AppCompatActivity; |
| 5 | +import android.os.Bundle; |
| 6 | +import android.support.v7.widget.LinearLayoutManager; |
| 7 | +import android.support.v7.widget.RecyclerView; |
| 8 | +import android.view.View; |
| 9 | + |
| 10 | +import com.clock.systemui.R; |
| 11 | +import com.clock.systemui.adapter.RecyclerItemAdapter; |
| 12 | + |
| 13 | +public class BottomSheetsDemoActivity extends AppCompatActivity implements View.OnClickListener { |
| 14 | + |
| 15 | + @Override |
| 16 | + protected void onCreate(Bundle savedInstanceState) { |
| 17 | + super.onCreate(savedInstanceState); |
| 18 | + setContentView(R.layout.activity_bottom_sheets_demo); |
| 19 | + |
| 20 | + findViewById(R.id.btn_show_dialog).setOnClickListener(this); |
| 21 | + |
| 22 | + } |
| 23 | + |
| 24 | + @Override |
| 25 | + public void onClick(View v) { |
| 26 | + int viewId = v.getId(); |
| 27 | + if (viewId == R.id.btn_show_dialog) { |
| 28 | + BottomSheetDialog dialog = new BottomSheetDialog(this); |
| 29 | + View contentView = View.inflate(this, R.layout.bottom_sheets_layout, null); |
| 30 | + RecyclerView itemView = (RecyclerView) contentView.findViewById(R.id.recycler_view); |
| 31 | + RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false); |
| 32 | + itemView.setLayoutManager(layoutManager); |
| 33 | + RecyclerView.Adapter adapter = new RecyclerItemAdapter(); |
| 34 | + itemView.setAdapter(adapter); |
| 35 | + dialog.setContentView(contentView); |
| 36 | + dialog.show(); |
| 37 | + } |
| 38 | + } |
| 39 | +} |
0 commit comments