当前位置: 编程技术>移动开发
本页文章导读:
▪列出目录上的所有图片 列出目录下的所有图片
public class GalleryTestActivity extends Activity {
File photos[];
private static String TAG = "GalleryTest";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanc.........
▪ 施用分享家V1.4.2版本发布 应用分享家V1.4.2版本发布
应用分享家V1.4.2 发布应用分享家(V1.4.2)是款能管理未安装的APK文件和已安装过程序的软件 在维持V1.1.2版本特性基础上,新增了: 1. 支持直接浏览本地应用管理.........
▪ 播发音乐时的状态条使用 播放音乐时的状态条使用
<ProgressBar android:id="@+id/progreso"
public class Player extends Activity implements Runnable, OnClickListener{
private TextView Status;
private ProgressBar progressBar;
private Button Star.........
[1]列出目录上的所有图片
来源: 互联网 发布时间: 2014-02-18
列出目录下的所有图片
public class GalleryTestActivity extends Activity {
File photos[];
private static String TAG = "GalleryTest";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
File f = new File("/sdcard/pics1");
photos = f.listFiles(new FilenameFilter() {
@Override
public boolean accept(File dir, String filename) {
return filename.endsWith("jpg");
}
});
String fileList = "";
for (File aFile : photos) {
fileList += aFile.getName() + "\n";
}
TextView v = (TextView)findViewById(R.id.FileList);
v.setText(fileList);
Gallery gallery = (Gallery)findViewById(R.id.Gallery);
gallery.setAdapter(new AddImgAdp(this));
}
public class AddImgAdp extends BaseAdapter {
int GalItemBg;
private Context cont;
public AddImgAdp(Context c) {
cont = c;
TypedArray typArray = obtainStyledAttributes(R.styleable.GalleryTheme);
GalItemBg = typArray.getResourceId(R.styleable.GalleryTheme_android_galleryItemBackground, 0);
typArray.recycle();
}
public int getCount() {
return photos.length;
}
public Object getItem(int position) {
return position;
}
public long getItemId(int position) {
return position;
}
public View getView(int position, View convertView, ViewGroup parent) {
ImageView imgView;
if (convertView == null)
imgView = new ImageView(cont);
else
imgView = (ImageView)convertView;
String filename = photos[position].getAbsolutePath();
Log.i(TAG, "Loading File " + filename);
Bitmap bMap = BitmapFactory.decodeFile(filename);
imgView.setImageBitmap(bMap);
imgView.setLayoutParams(new Gallery.LayoutParams(120, 90));
imgView.setScaleType(ImageView.ScaleType.FIT_XY);
imgView.setBackgroundResource(GalItemBg);
return imgView;
}
}
}
[2] 施用分享家V1.4.2版本发布
来源: 互联网 发布时间: 2014-02-18
应用分享家V1.4.2版本发布
应用分享家V1.4.2 发布
应用分享家(V1.4.2)是款能管理未安装的APK文件和已安装过程序的软件
在维持V1.1.2版本特性基础上,新增了:
1. 支持直接浏览本地应用管理界面
2. 支持创建快捷方式
3. 支持在电子市场中搜索
4. 对应用列表按照应用时间进行了排序
===============
附件有下载包,请试用。如有不妥,请指教.
如果不能安装,请去除zip后缀名,改为apk后缀名.
应用分享家V1.4.2 发布
应用分享家(V1.4.2)是款能管理未安装的APK文件和已安装过程序的软件
在维持V1.1.2版本特性基础上,新增了:
1. 支持直接浏览本地应用管理界面
2. 支持创建快捷方式
3. 支持在电子市场中搜索
4. 对应用列表按照应用时间进行了排序
===============
附件有下载包,请试用。如有不妥,请指教.
如果不能安装,请去除zip后缀名,改为apk后缀名.
[3] 播发音乐时的状态条使用
来源: 互联网 发布时间: 2014-02-18
播放音乐时的状态条使用
<ProgressBar android:id="@+id/progreso"
public class Player extends Activity implements Runnable, OnClickListener{
private TextView Status;
private ProgressBar progressBar;
private Button StartMedia;
private Button Stop;
private MediaPlayer mp;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Status = (TextView) findViewById(R.id.Status);
progressBar = (ProgressBar) findViewById(R.id.progressBar);
StartMedia = (Button) findViewById(R.id.StartMedia);
Stop = (Button) findViewById(R.id.Stop);
StartMedia.setOnClickListener(this);
Stop.setOnClickListener(this);
}
@Override
public void onClick(View v) {
if(v.equals(StartMedia)){
if(mp != null && mp.isPlaying()) return;
mp = MediaPlayer.create(Player.this, R.raw.exodus_piranha);
mp.start();
Status.setText(R.string.PlayingMedia);
progressBar.setVisibility(ProgressBar.VISIBLE);
progressBar.setProgress(0);
progressBar.setMax(mp.getDuration());
new Thread(this).start();
}
if(v.equals(Stop) && mp!=null){
mp.stop();
mp = null;
Status.setText(R.string.Stopped);
progressBar.setVisibility(ProgressBar.GONE);
}
}
@Override
public void run() {
int CurrentPosition= 0;
int total = mp.getDuration();
while(mp!=null && CurrentPosition<total){
try {
Thread.sleep(1000);
CurrentPosition= mp.getCurrentPosition();
} catch (InterruptedException e) {
return;
} catch (Exception e){
return;
}
progressBar.setProgress(CurrentPosition);
}
}
}
最新技术文章: