Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
Hello UTS
提交
2c93d76d
H
Hello UTS
项目概览
DCloud
/
Hello UTS
通知
1595
Star
27
Fork
9
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
2
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
Hello UTS
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
2
Issue
2
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
2c93d76d
编写于
12月 20, 2022
作者:
lizhongyi_
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'dev_lzy' into dev
* dev_lzy: native page 增加了 recycleview 示例
上级
7bdad3b5
dc15293a
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
76 addition
and
0 deletion
+76
-0
uni_modules/uts-nativepage/utssdk/app-android/config.json
uni_modules/uts-nativepage/utssdk/app-android/config.json
+6
-0
uni_modules/uts-nativepage/utssdk/app-android/index.uts
uni_modules/uts-nativepage/utssdk/app-android/index.uts
+51
-0
uni_modules/uts-nativepage/utssdk/app-android/res/layout/demo_activity.xml
...ativepage/utssdk/app-android/res/layout/demo_activity.xml
+8
-0
uni_modules/uts-nativepage/utssdk/app-android/res/layout/fruit_item.xml
...s-nativepage/utssdk/app-android/res/layout/fruit_item.xml
+11
-0
未找到文件。
uni_modules/uts-nativepage/utssdk/app-android/config.json
0 → 100644
浏览文件 @
2c93d76d
{
"dependencies"
:
[
"androidx.recyclerview:recyclerview:1.0.0"
]
}
uni_modules/uts-nativepage/utssdk/app-android/index.uts
浏览文件 @
2c93d76d
...
...
@@ -28,6 +28,11 @@ import Class from 'java.lang.Class';
import Exception from 'java.lang.Exception';
import PackageManager from 'android.content.pm.PackageManager';
import ResolveInfo from 'android.content.pm.ResolveInfo';
import RecyclerView from 'androidx.recyclerview.widget.RecyclerView';
import TextView from 'android.widget.TextView';
import ViewGroup from 'android.view.ViewGroup';
import LayoutInflater from 'android.view.LayoutInflater';
import LinearLayoutManager from 'androidx.recyclerview.widget.LinearLayoutManager';
...
...
@@ -171,6 +176,46 @@ class CustomThread extends Thread{
}
}
class FruitAdapter extends RecyclerView.Adapter<FruitAdapter.ViewHolder>{
mFruitList: Array<String>
constructor(param:Array<String>){
mFruitList = param
}
ViewHolder = class extends RecyclerView.ViewHolder {
fruitName:TextView;
constructor(view:View) {
super(view);
fruitName = view.findViewById(R.id.fruit_name) as TextView;
}
}
override onCreateViewHolder(
parent: ViewGroup,
viewType: Int
): ViewHolder {
let view: View =
LayoutInflater.from(parent.context).inflate(R.layout.fruit_item, parent, false)
return ViewHolder(view)
}
override onBindViewHolder(holder: ViewHolder, position: Int) {
let fruit: String = mFruitList[position]
holder.fruitName.setText(fruit)
}
override getItemCount(): Int {
return mFruitList.size
}
}
class DemoActivity extends Activity{
constructor (){
...
...
@@ -190,6 +235,12 @@ class DemoActivity extends Activity{
let btn_start_thread = findViewById<Button>(R.id.btn_start_thread);
btn_start_thread.setOnClickListener(new StartThreadListener());
let recyclerView = findViewById<RecyclerView>(R.id.recycler_view)
let layoutManager = LinearLayoutManager(this);
recyclerView.setLayoutManager(layoutManager);
let fruitAdapter = FruitAdapter(arrayListOf("香蕉","苹果","大鸭梨"));
recyclerView.setAdapter(fruitAdapter);
}
}
...
...
uni_modules/uts-nativepage/utssdk/app-android/res/layout/demo_activity.xml
浏览文件 @
2c93d76d
...
...
@@ -8,4 +8,12 @@
<Button
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:text=
"开启前台服务(应用包活)"
android:id=
"@+id/btn_start_service_front"
/>
<Button
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:text=
"注册屏幕状态广播监听"
android:id=
"@+id/btn_start_screen_listen"
/>
<Button
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:text=
"开启异步任务"
android:id=
"@+id/btn_start_thread"
/>
<androidx.recyclerview.widget.RecyclerView
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:id=
"@+id/recycler_view"
>
</androidx.recyclerview.widget.RecyclerView>
</LinearLayout>
\ No newline at end of file
uni_modules/uts-nativepage/utssdk/app-android/res/layout/fruit_item.xml
0 → 100644
浏览文件 @
2c93d76d
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:orientation=
"horizontal"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:id=
"@+id/fruit_name"
/>
</LinearLayout>
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录