初次提交

This commit is contained in:
2022-09-19 18:05:01 +08:00
commit 57051fc44b
5401 changed files with 325410 additions and 0 deletions

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Sample2_5</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View File

@@ -0,0 +1,5 @@
#Wed Jun 22 19:48:38 CST 2011
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
org.eclipse.jdt.core.compiler.compliance=1.5
org.eclipse.jdt.core.compiler.source=1.5

View File

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
android:versionCode="1"
android:versionName="1.0" package="com.bn.pp5">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".Sample2_5_Activity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

View File

@@ -0,0 +1,11 @@
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system use,
# "build.properties", and override values to adapt the script to your
# project structure.
# Project target.
target=android-7

View File

@@ -0,0 +1,31 @@
/* AUTO-GENERATED FILE. DO NOT MODIFY.
*
* This class was automatically generated by the
* aapt tool from the resource data it found. It
* should not be modified by hand.
*/
package com.bn.pp5;
public final class R {
public static final class attr {
}
public static final class drawable {
public static final int icon=0x7f020000;
}
public static final class id {
public static final int Button01=0x7f050003;
public static final int EditText01=0x7f050002;
public static final int EditText02=0x7f050005;
public static final int LinearLayout01=0x7f050000;
public static final int ScrollView01=0x7f050004;
public static final int TextView01=0x7f050001;
}
public static final class layout {
public static final int main=0x7f030000;
}
public static final class string {
public static final int app_name=0x7f040001;
public static final int hello=0x7f040000;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

View File

@@ -0,0 +1,53 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:text="文件IO--访问SD卡"
android:layout_width="fill_parent"
android:textSize="16dip"
android:layout_height="wrap_content"
android:gravity="center"
/>
<LinearLayout
android:id="@+id/LinearLayout01"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView
android:text="文件名:"
android:textSize="18dip"
android:id="@+id/TextView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</TextView>
<EditText
android:text="AndroidIO.txt"
android:id="@+id/EditText01"
android:singleLine="true"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</EditText>
<Button
android:text="打开文件"
android:id="@+id/Button01"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</Button>
</LinearLayout>
<ScrollView
android:id="@+id/ScrollView01"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<EditText
android:text=""
android:id="@+id/EditText02"
android:editable="false"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
</EditText>
</ScrollView>
</LinearLayout>

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello">Hello World, Sample3_1_Activity!</string>
<string name="app_name">Sample2_5</string>
</resources>

View File

@@ -0,0 +1,43 @@
package com.bn.pp5;
import java.io.File; //引入相关包
import java.io.FileInputStream;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class Sample2_5_Activity extends Activity { //创建Activity
@Override
public void onCreate(Bundle savedInstanceState) { //重写onCreate方法
super.onCreate(savedInstanceState);
setContentView(R.layout.main); //设置layout
Button ok=(Button)this.findViewById(R.id.Button01); //获取打开Button
ok.setOnClickListener //为打开按钮添加监听器
( new OnClickListener()
{ public void onClick(View v)
{ EditText et1=(EditText)findViewById(R.id.EditText01);
//调用loadText方法获取对应文件名的文件
String nr=loadText(et1.getText().toString().trim());
EditText et2=(EditText)findViewById(R.id.EditText02);
//设置显示框内容
et2.setText(nr);
}});}
public String loadText(String name) //加载SD卡文件方法
{ String nr=null; //内容字符串
try
{ File f=new File("/sdcard/"+name); //创建对应文件
byte[] buff=new byte[(int) f.length()]; //创建响应大小的byte数组
FileInputStream fis=new FileInputStream(f);
fis.read(buff); //读入文件
fis.close(); //关闭输入流
nr=new String(buff,"utf-8"); //转码生成字符串
nr=nr.replaceAll("\\r\\n","\n");} //替换换行符
catch (Exception e)
{ //没有找到文件提示
Toast.makeText(getBaseContext(), "对不起,没有找到指定文件。", Toast.LENGTH_LONG).show(); }
return nr; //返回内容字符串
}}