简体   繁体   English

将图片网址加载到editText中

[英]load image url into editText

I need to insert a URL Image into EditText and able to save it to my Mysql . 我需要将URL图像插入EditText并将其保存到Mysql中

  • I need to broswe all the images from my local server ( SOLVED ). 我需要浏览来自本地服务器的所有图像(已解决 )。
  • Then I want to select one image and display the selected url image into a EditText( Problem ). 然后,我想选择一个图像并将选定的URL图像显示为EditText( Problem )。
  • So that I will save the selected url image into mysql database ( No Problem with that ) 这样我就可以将选定的URL图像保存到mysql数据库中( 没问题
  • Pluz how to return to my form after i selected the image ( Problem ) 选择图像后,Pluz如何返回我的表单( 问题

Here my code for browsing the list of images into my local server : 这是我的代码,用于将图像列表浏览到本地服务器中:

checkButton=(Button) findViewById(R.id.browser);

        checkButton.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {

            String url = "http://10.0.2.2/images/";
            Intent i = new Intent(Intent.ACTION_VIEW);
            i.setData(Uri.parse(url));
            startActivity(i);

        }

        }); 

if you have URL for image, then you can retrieve Bitmap for image from server. 如果您有图像的URL,则可以从服务器检索图像的位图。 then you can build a Drwable from Bitmap- 然后您可以从Bitmap构建Drwable-

    Drawable d =new BitmapDrawable(bitmap);

And then for setting background in EditText 然后在EditText中设置背景

 editText.setBackgroundDrawable(d);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM