安卓查看特定文件,并按钮查看下一个或上一个
来源:互联网 发布:mysql高级视频教程 编辑:程序博客网 时间:2024/06/06 13:57
为下一篇打底
import android.app.Activity;import android.os.Bundle;import android.os.Environment;import android.util.Log;import android.view.View;import android.widget.Button;import android.widget.TextView;import android.widget.Toast;import java.io.File;import static android.widget.Toast.LENGTH_SHORT;/** * Created by 允琪 on 2017/5/14. */public class NextFile extends Activity{ public String sdPath = "/sdcard/File/"; public File folder; public String [] allFile; public String scanpath; private Button zhege,xiage; private TextView textView; private int flag = 0; protected void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.nextfile_layout); zhege = (Button) findViewById(R.id.zhege); xiage = (Button) findViewById(R.id.xiage); textView = (TextView)findViewById(R.id.text); folder = new File(sdPath); allFile = folder.list(); final String a = allFile[1]; for (int i = 0 ;i < allFile.length;i++){ scanpath = Environment.getExternalStorageState().toString()+sdPath+allFile[i]; Log.d("scanpath",scanpath); } zhege.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { scanpath = Environment.getExternalStorageState().toString()+sdPath+allFile[flag]; Toast.makeText(NextFile.this,"当前位于 文件"+allFile[flag],Toast.LENGTH_SHORT).show(); } }); xiage.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { ++flag; scanpath = Environment.getExternalStorageState().toString()+sdPath+allFile[flag]; Toast.makeText(NextFile.this,"当前位于 文件"+allFile[flag],Toast.LENGTH_SHORT).show(); } }); }}
layout文件
<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <Button android:text="This" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="238dp" android:id="@+id/zhege" android:layout_alignParentBottom="true" android:layout_toLeftOf="@+id/text" android:layout_toStartOf="@+id/text" android:layout_marginRight="34dp" android:layout_marginEnd="34dp"/> <Button android:text="Next" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginRight="31dp" android:layout_marginEnd="31dp" android:id="@+id/xiage" android:layout_alignBaseline="@+id/zhege" android:layout_alignBottom="@+id/zhege" android:layout_alignParentRight="true" android:layout_alignParentEnd="true"/> <TextView android:text="TextView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/text" android:layout_above="@+id/zhege" android:layout_centerHorizontal="true" android:layout_marginBottom="64dp"/></RelativeLayout>
阅读全文
0 0
- 安卓查看特定文件,并按钮查看下一个或上一个
- 实现读取某文件夹下txt、图片,并按钮点击上一个下一个文件中的txt,图片
- 按钮,下一个或者上一个
- js 按钮下一个上一个滚动效果
- 安卓源码查看
- 转换或查看lwp文件
- 【Android】安卓开发之将上一个Activity的数据传递给下一个Activity
- Sql Server设置用户只能查看并访问特定数据库
- eclipse查看安卓源码
- 查看安卓apk源码
- CMD查看安卓密钥
- 查看安卓应用签名
- 安卓实现查看通话记录
- 安卓wiifi密码查看
- 安卓查看网络状态
- 输入日期的上一个或下一个星期X
- linux查看文件或文件夹大小
- linux命令--查看文件或文件夹大小
- LeetCode 303. Range Sum Query
- 超全整理!Linux性能分析工具汇总合集
- jQuery中的DOM节点的创建与多种插入方式
- (3/500)在线性时间内对二进制数组排序
- 基本数据类型
- 安卓查看特定文件,并按钮查看下一个或上一个
- 【Maven学习】maven中依赖的配置详解
- CSS的伪类选择器
- 静态 常量 同步
- sql365 行转列,同时根据公司编码带上公司名称
- XSS也能getshell
- 我们离所谓的优秀有多远
- d3.v4.js 绘制曲线图, 支持鼠标悬停显示数值
- 杨氏矩阵