English 中文(简体)
灯塔显示器具,回归形象作为轨道图
原标题:Android load gallery onclick, return image as bitmap

我很难从一项活动中恢复信息,我对执行情况的理解并不全面。

我想要的是,用户能够点击一个顿子,装上 and子,选择图像,将图像(或与图像链接)转换成一个插图/可选择,这在我的活动中见到。

我有刺 the乐机开张,但我没有从那里得到任何反应(我知道,为什么在彩礼中没有任何意图——我有这样做的机会,以便洗衣,但我知道解决办法)。

 ImageView galleryClick = (ImageView)findViewById(R.id.addgallery);

    profilePic = (ImageView)findViewById(R.id.profilepic);

    galleryClick.setOnClickListener(new OnClickListener(){

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            Intent intent = new Intent(Intent.ACTION_GET_CONTENT);  
            intent.setType("image/*");

            startActivityForResult(Intent.createChooser(intent, "Select Picture"),1);

        }

    });

我所希望的是,在我的手写活动中,将呼吁开展主动活动,但这一方法从未被称作(我在其法典中规定一个突破点)。

 public void onActivityResult(int requestCode, int resultCode, Intent data) { 

   if (resultCode == RESULT_OK) {

       if (requestCode == 1) {
          // currImageURI is the global variable I m using to hold the content:// URI of the image
          //currImageURI = data.getData();
       }
    }
}

解决办法?

最佳回答

如果我正确理解你的问题,我认为以前在Stack Overflow上曾提出过类似的问题。 这里指的是:

Get/pick an pornography from sendo-in Line app programally

问题回答

使用:

 ImageView user_Image = (ImageView) headerView.findViewById(R.id.user_image);

user_Image.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            openImageChooser();
        }
    });

private void openImageChooser() {
    Intent intent = new Intent();
    intent.setType("image/*");
    intent.setAction(Intent.ACTION_GET_CONTENT);
    startActivityForResult(Intent.createChooser(intent, "Select Picture"), SELECT_PICTURE);
}

public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode == RESULT_OK)
    {
        if (requestCode == SELECT_PICTURE)
        {
            // Get the url from data
            Uri selectedImageUri = data.getData();
            if (null != selectedImageUri)
            {
                // Get the path from the Uri
                String path = getPathFromURI(selectedImageUri);
                Log.i(TAG, "Image Path : " + path);
                // Set the image in ImageView
                ((ImageView) findViewById(R.id.user_image)).setImageURI(selectedImageUri);
            }
        }
    }
}




相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签