我的布局是我的图片和文字文件在" res / raw"文件夹由用户搜索加载。 图像的名称以(" p" +月+" _" +天)开头,文本文件以" t"开头。 当用户搜索日期时,java按月和日创建文件名。 但这并不是像平板电脑10和平板电脑那样在某些平台上显示图像和文字。 &安培;索尼xperia T
图像
String MD = (jCal.toString().substring(5)); // 2014-03-25 => 03-25
String[] Split_MD = MD.split("-");
String mDrawableName = ("p"+Split_MD[0]+"_"+Split_MD[1]);
ImageView Pic = (ImageView) findViewById(R.id.imageView);
Resources res = getResources();
int resId = res.getIdentifier(mDrawableName, "raw", getPackageName());
Pic.setImageResource(resId);
文本
TextView txtContent = (TextView) findViewById(R.id.date);
String mAssetsName = ("raw/t"+Split_MD[0]+"_"+Split_MD[1]);
txtContent.setTypeface(face);
try {
Resources res1 = getResources();
InputStream in_s = res1.openRawResource(getResources().getIdentifier(mAssetsName,"raw", getPackageName()));
byte[] b = new byte[in_s.available()];
in_s.read(b);
txtContent.setText(new String(b));
} catch (Exception e) {
// e.printStackTrace();
txtContent.setText("Error: can't show help.");
}
logcat的:
D/dalvikvm﹕ Not late-enabling CheckJNI (already on)
E/Trace﹕ error opening trace file: No such file or directory (2)
D/dalvikvm﹕ GC_FOR_ALLOC freed 39K, 7% free 2430K/2592K, paused 72ms, total 77ms
I/dalvikvm-heap﹕ Grow heap (frag case) to 3.075MB for 614416-byte allocation
D/dalvikvm﹕ GC_FOR_ALLOC freed 1K, 6% free 3029K/3196K, paused 66ms, total 66ms
D/dalvikvm﹕ GC_CONCURRENT freed <1K, 6% free 3029K/3196K, paused 8ms+5ms, total 90ms
D/gralloc_goldfish﹕ Emulator without GPU emulation detected.
I/Choreographer﹕ Skipped 32 frames! The application may be doing too much work on its main thread.
I/Choreographer﹕ Skipped 68 frames! The application may be doing too much work on its main thread.
D/dalvikvm﹕ GC_FOR_ALLOC freed 21K, 5% free 3184K/3328K, paused 253ms, total 273ms
I/dalvikvm-heap﹕ Grow heap (frag case) to 3.810MB for 614416-byte allocation
D/dalvikvm﹕ GC_CONCURRENT freed 4K, 4% free 3779K/3932K, paused 12ms+69ms, total 253ms
I/Choreographer﹕ Skipped 42 frames! The application may be doing too much work on its main thread.