public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
BottomMenuView bmv_list = (BottomMenuView) findViewById(R.id.bmv_list);
//设置bottom数据
bmv_list.setBottomItem(getData());
//监听点击事件
bmv_list.setBottomItemOnClickListener(new BottomMenuView.BottomItemOnClickListener() {
@Override
public void bottomItemOnClick(View view, int i, BottomItem item) {
Toast.makeText(getApplicationContext(),"点击了第"+i+"个",Toast.LENGTH_SHORT).show();
}
});
//默认选择第几个
bmv_list.setShowIndex(0);
}
/**
* 创建bottom数据
* @return
*/
public List getData(){
List items = new ArrayList<>();
items.add(new BottomItem("首页",R.mipmap.icon_function_tab));
items.add(new BottomItem("信息",R.mipmap.icon_home_tab));
items.add(new BottomItem("应用",R.mipmap.icon_my_tab));
items.add(new BottomItem("我的",R.mipmap.icon_home_tab));
return items;
}
}
Bottomitem的代码
public class BottomItem {
private String name;
private int icon;
public BottomItem(String name, int icon) {
this.name = name;
this.icon = icon;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getIcon() {
return icon;
}
public void setIcon(int icon) {
this.icon = icon;
}
}
是不是很方便呢!
现在来BottomMenuView看看是怎么实现的
public class BottomMenuView extends LinearLayout implements View.OnClickListener{
private static final String TAG = "BottomMenuView";
private Context mContext;
private int imgColor = 0xff009AFF;//点击改变图片颜色
private int imgDefaultColor = 0xff565656;//默认图片颜色
private float textSize = 12; //字体大小
private int imgPadding = 12; //内边距
private List bottomItems;//Item列表
private List
1. If语句作为表达式
val properties = if (jobIdToActiveJob.contains(jobId)) {
jobIdToActiveJob(stage.jobId).properties
} else {
// this stage will be assigned to "default" po
基础测试题
卷面上不能出现任何的涂写文字,所有的答案要求写在答题纸上,考卷不得带走。
选择题
1、 What will happen when you attempt to compile and run the following code? (3)
public class Static {
static {
int x = 5; // 在static内有效
}
st
表里的一行对于一个数据块太大的情况有二种(一行在一个数据块里放不下)
第一种情况:
INSERT的时候,INSERT时候行的大小就超一个块的大小。Oracle把这行的数据存储在一连串的数据块里(Oracle Stores the data for the row in a chain of data blocks),这种情况称为行链接(Row Chain),一般不可避免(除非使用更大的数据
Follow up for "Remove Duplicates":What if duplicates are allowed at most twice?
For example,Given sorted array nums = [1,1,1,2,2,3],
Your function should return length