package geeker.MyActivity;
import android.app.Activity;
import android.os.Bundle;
import android.widget.Button;
import android.widget.TextView;
public class MyActivity extends Activity {
//成员变量的声明
private TextView myTextView = null;
private Button myButton = null;
//重写OnCreate方法,会自动生成
public void onCreate(Bundle savedInstanceState) {
//调用父类方法,该句代码自动生成
super.onCreate(savedInstanceState);
//通过布局文件的id调用该Activity所使用的布局文件
setContentView(R.layout.main);
//通过findViewById()方法拿到布局文件中添加的控件
//不过在布局文件中添加控件的时候必须定义id号,
//如:android:id="@+id/myTextView"
myTextView = (TextView)findViewById(R.id.myTextView);
myButton = (Button)findViewById(R.id.myButton);
//向控件上制定显示文字
myTextView.setText("This is my first Activity !");
myButton.setText("MY FIRST BUTTON");
}
}
<?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:id="@+id/myTextView" android:layout_width="fill_parent" android:layout_height="wrap_content" /> <Button android:id="@+id/myButton" android:layout_width="fill_parent" android:layout_height="wrap_content" /> </LinearLayout>
/* 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 geeker.MyActivity;
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 myButton=0x7f050001;
public static final int myTextView=0x7f050000;
}
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;
}
}
<Button android:id="@+id/myButton" android:layout_width="fill_parent" android:layout_height="wrap_content" />
public static final class id {
public static final int myButton=0x7f050001;
public static final int myTextView=0x7f050000;
}
private Button myButton = null;
myButton = (Button)findViewById(R.id.myButton);
myButton.setText("MY FIRST BUTTON");
<activity android:name=".MyActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
package net.nowamagic.file;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import android.util.Log;
/**
* @author
* function 用于扫描SD卡上的文件
*
*/
public class FileScan {
private static final String TAG = "FileScan";
public HashMap<String, String> getMusicListOnSys(File file) {
//从根目录开始扫描
Log.i(TAG, file.getPath());
HashMap<String, String> fileList = new HashMap<String, String>();
getFileList(file, fileList);
return fileList;
}
/**
* @param path
* @param fileList
* 注意的是并不是所有的文件夹都可以进行读取的,权限问题
*/
private void getFileList(File path, HashMap<String, String> fileList){
//如果是文件夹的话
if(path.isDirectory()){
//返回文件夹中有的数据
File[] files = path.listFiles();
//先判断下有没有权限,如果没有权限的话,就不执行了
if(null == files)
return;
for(int i = 0; i < files.length; i++){
getFileList(files[i], fileList);
}
}
//如果是文件的话直接加入
else{
Log.i(TAG, path.getAbsolutePath());
//进行文件的处理
String filePath = path.getAbsolutePath();
//文件名
String fileName = filePath.substring(filePath.lastIndexOf("/")+1);
//添加
fileList.put(fileName, filePath);
}
}
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有