小编Kai*_*bhi的帖子

动态获取数组中的所有图像资源ID

在drawable foder中有很多图像,所以相反手动创建所有图像资源ID的数组,我想动态获取数组中可绘制文件夹的所有图像.目前即时使用此代码:

for(int i=1;i<=9;i++)
    {
            int imageKey = getResources().getIdentifier("img"+i, "drawable", getPackageName());
            ImageView image = new ImageView(this);  
            image.setId(imgId);
            image.setImageResource(imageKey);    
            image.setScaleType(ImageView.ScaleType.FIT_XY);
            viewFlipper.addView(image, new LayoutParams(LayoutParams.FILL_PARENT,              LayoutParams.FILL_PARENT));
            imgId++;
        }
Run Code Online (Sandbox Code Playgroud)

但在该代码中我需要手动编辑图像名称以获取资源ID但我想获得任何名称的所有图像..

android

11
推荐指数
2
解决办法
1万
查看次数

恢复将数据放入JSONObject的顺序

我希望有json,因为它插入此代码,但它的工作原理不同!我首先要CustomerID,然后Name这个json给出第Name一个然后CustomerID.我已经插入了json,但是为什么它会给出不同的结果请帮帮我..

    JSONObject json = new JSONObject();

    try {
        json.put("CustomerID", "069C21F1-EE87-4FB4-A129-478AEAA454FF");
        json.put("Name", "Name_" + (int) Math.random() * 1000);
} catch (JSONException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
Run Code Online (Sandbox Code Playgroud)

android json

3
推荐指数
1
解决办法
3638
查看次数

想在真正的手机上看到logcat

我的应用程序在模拟器上运行非常好没有任何logcat错误,但它突然crashed在真正的Android设备上.所以我想在真正的Android平板电脑上看到logcat.我已经失去了我的usb connector所以请告诉我一些东西,所以我可以logcat在Android平板电脑上查看.请给我一些想法.提前致谢.

android android-emulator

2
推荐指数
1
解决办法
1150
查看次数

想完全关闭应用程序

我想关闭我的整个申请.我已经尝试过finishActivity()背压,但它不起作用.我想完全关闭我在back新闻发布会上的申请.我怎么能这样做?

 public void onImageViewClicked(View view){
        switch(view.getId()){
            case R.id.viewStk:
intent = new Intent(MainActivity.this,ViewStkActivity.class);
                startActivityForResult(intent, 12);
                break;
            case R.id.about:
                Intent aboutIntent = new  Intent(MainActivity.this,AboutActivity.class);
                startActivity(aboutIntent);
                break;
    } 

}
Run Code Online (Sandbox Code Playgroud)

android android-intent

1
推荐指数
2
解决办法
862
查看次数

标签 统计

android ×4

android-emulator ×1

android-intent ×1

json ×1