public class DisPlayPic extends Activity {
ImageView imagev;
int count = 1;
String str="/sdcard/daa_";
String str1=".bmp";
String str2; /** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.main);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);//设置全屏显示
imagev = (ImageView) findViewById(R.id.imgv);
new Thread(new TimePrinter()).start();
}
class TimePrinter implements Runnable{ @Override
public void run() {
while(true){
str2=str+String.valueOf(count)+str1;
File f=new File(str2);
if(f.exists())
{
Bitmap bmp = BitmapFactory.decodeFile(str2);
// BitmapDrawable bmpDraw=new BitmapDrawable(bmp);
//imagev.setImageDrawable(bmpDraw);
imagev.setImageBitmap(bmp);
count++;
}
else
{
count=1;
str2=str+String.valueOf(count)+str1;
Bitmap bmp = BitmapFactory.decodeFile(str2);
// BitmapDrawable bmpDraw=new BitmapDrawable(bmp);
//imagev.setImageDrawable(bmpDraw);
imagev.setImageBitmap(bmp);
}
}
}
}
}
问题是我的程序只能读第一张图片,读第二张程序就弹出错误,为什么呢?
ImageView imagev;
int count = 1;
String str="/sdcard/daa_";
String str1=".bmp";
String str2; /** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.main);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);//设置全屏显示
imagev = (ImageView) findViewById(R.id.imgv);
new Thread(new TimePrinter()).start();
}
class TimePrinter implements Runnable{ @Override
public void run() {
while(true){
str2=str+String.valueOf(count)+str1;
File f=new File(str2);
if(f.exists())
{
Bitmap bmp = BitmapFactory.decodeFile(str2);
// BitmapDrawable bmpDraw=new BitmapDrawable(bmp);
//imagev.setImageDrawable(bmpDraw);
imagev.setImageBitmap(bmp);
count++;
}
else
{
count=1;
str2=str+String.valueOf(count)+str1;
Bitmap bmp = BitmapFactory.decodeFile(str2);
// BitmapDrawable bmpDraw=new BitmapDrawable(bmp);
//imagev.setImageDrawable(bmpDraw);
imagev.setImageBitmap(bmp);
}
}
}
}
}
问题是我的程序只能读第一张图片,读第二张程序就弹出错误,为什么呢?
解决方案 »
- 求助,Activities can't be added until the containing group has been created
- android 读取资源图片有大小的限制吗
- 官方市场更新应用出现:服务器无法处理您的apk, 请重试
- 请问一下Android中VideoView的问题
- 如何搭建Android的开发环境啊。
- 为什么在国内android market会搜索出很多韩国应用
- 怎么样实现 “音频 变声”
- 怎么创建?
- android 源码修改,让源生的那个组Activity变成拨号的界面!
- 单片机发送1000HZ手机音频口怎么得出是1000HZ
- android menu问题
- arcgis android
对头 结贴吧 请你看看这个帖子
http://topic.csdn.net/u/20110415/16/f16b9d6d-2cb6-46e5-bb5c-02620732cd4d.html?8650