listView.setAdapter(listAdapter);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
String kind = (String) listAdapter.getItem(i);
if(itemClickListener != null){
itemClickListener.onClick(kind);
}
}
});
setContentView(view);
Window window = getWindow();
WindowManager.LayoutParams params = window.getAttributes();
params.gravity = Gravity.START;
params.width = 500;
window.setAttributes(params);//通过window来设置窗口的位置,Start就是屏幕左侧,设置宽度为500px
}
//自定义接口
interface ItemClickListener{
void onClick(String s);
}
}
布局文件代码如下:
<?xml version="1.0" encoding="utf-8"?><androidx.cardview.widget.CardView xmlns:android=“http://schemas.android.com/apk/res/android”
android:layout_width=“160dp”
android:layout_height=“match_parent”
xmlns:app=“http: Android开源项目《ali1024.coding.net/public/P7/Android/git》 //schemas.android.com/apk/res-auto”
app:cardCornerRadius=“10dp”
app:cardElevation=“0dp”
app:cardBackgroundColor="#ffffff">
<RelativeLayout
android:layout_width=“160dp”
android:layout_height=“match_parent”>
<TextView
android:id="@+id/title"
android:layout_width=“match_parent”
android:layout_height=“wrap_content”
android:text=“便签分组”
android:textSize=“17sp”
android:layout_centerHorizontal=“true”
android:gravity=“center”
android:layout_marginTop=“20dp”
android:layout_marginBottom=“20dp”/>
<View
android:layout_width=“match_parent”
android:layout_height=“1dp”
android:layout_below="@+id/title"
android:background="#000000"/>
<ListView
android:id="@+id/list_view"
android:layout_width=“match_parent”
androi 《Android学习笔记总结+最新移动架构视频+大厂安卓面试真题+项目实战源码讲义》开源 d:layout_height=“match_parent”
android:layout_below="@+id/title"/>
总结
现在新技术层出不穷,如果每次出新的技术,我们都深入的研究的话,很容易分散精力。新的技术可能很久之后我们才会在工作中用得上,当学的新技术无法学以致用,很容易被我们遗忘,到最后真的需要使用的时候,又要从头来过(虽然上手会更快)。
我觉得身为技术人,针对新技术应该是持拥抱态度的,入了这一行你就应该知道这是一个活到老学到老的行业,所以面对新技术,不要抵触,拥抱变化就好了。
Flutter 明显是一种全新的技术,而对于这个新技术在发布之初,花一个月的时间学习它,成本确实过高。但是周末花一天时间体验一下它的开发流程,了解一下它的优缺点、能干什么或者不能干什么。这个时间,并不是我们不能接受的。
如果有时间,其实通读一遍 Flutter 的文档,是最全面的一次对 Flutter 的了解过程。但是如果我们只有 8 小时的时间,我希望能关注一些最值得关注的点。