第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定

正在回答

1 回答

//MainActivity

package com.example.administrator.task_test;


import android.content.Intent;

import android.support.v7.app.AppCompatActivity;

import android.os.Bundle;

import android.util.Log;

import android.view.View;

import android.widget.EditText;


public class MainActivity extends AppCompatActivity {

? ? EditText editText;

? ? public static String url_temp;

? ? @Override

? ? protected void onCreate(Bundle savedInstanceState) {

? ? ? ? super.onCreate(savedInstanceState);

? ? ? ? setContentView(R.layout.activity_main);



? ? }

? ? public void loadImage(View v)

? ? {

? ? ? ? editText= (EditText) findViewById(R.id.editText);

? ? ? ? url_temp=editText.getText().toString();

? ? ? ? Log.i("sasaki", "loadImage");

? ? ? ? Intent intent=new Intent(MainActivity.this,ImageTest.class);

? ? ? ? startActivity(intent);

? ? }

}

//ImageTest?

package com.example.administrator.task_test;


import android.app.Activity;

import android.graphics.Bitmap;

import android.graphics.BitmapFactory;

import android.os.AsyncTask;

import android.os.Bundle;

import android.util.Log;

import android.view.View;

import android.widget.ImageView;

import android.widget.ProgressBar;


import java.io.BufferedInputStream;

import java.io.IOException;

import java.io.InputStream;

import java.net.URL;

import java.net.URLConnection;


/**

?* Created by Administrator on 2016/1/30 0030.

?*/

public class ImageTest extends Activity{

? ? ImageView imageView;

? ? ProgressBar progressBar;

? ? static String URL=MainActivity.url_temp;

? ? @Override

? ? protected void onCreate(Bundle savedInstanceState) {

? ? ? ? super.onCreate(savedInstanceState);

? ? ? ? setContentView(R.layout.imagetest);

? ? ? ? Log.i("url傳輸", URL);

? ? ? ? imageView= (ImageView) findViewById(R.id.imageView);

? ? ? ? progressBar= (ProgressBar) findViewById(R.id.progressBar);

? ? ? ? MyAsyncTask myAsyncTask=new MyAsyncTask();

? ? ? ? myAsyncTask.execute(URL);


? ? }

? ? class MyAsyncTask extends AsyncTask<String,Void,Bitmap>

? ? {

? ? ? ? @Override

? ? ? ? protected void onPreExecute() {

? ? ? ? ? ? super.onPreExecute();

? ? ? ? ? ? Log.i("sasaki", "onPreExecute");

? ? ? ? ? ? progressBar.setVisibility(View.VISIBLE);

? ? ? ? }


? ? ? ? @Override

? ? ? ? protected void onPostExecute(Bitmap bitmap) {

? ? ? ? ? ? super.onPostExecute(bitmap);

? ? ? ? ? ? Log.i("sasaki", "onPostExecute");

? ? ? ? ? ? progressBar.setVisibility(View.GONE);

? ? ? ? ? ? imageView.setImageBitmap(bitmap);

? ? ? ? }


? ? ? ? @Override

? ? ? ? protected Bitmap doInBackground(String... params) {

? ? ? ? ? ? Log.i("sasaki","doInBackground");

? ? ? ? ? ? String url=params[0];

? ? ? ? ? ? URLConnection connection;

? ? ? ? ? ? InputStream is;

? ? ? ? ? ? BufferedInputStream bis;

? ? ? ? ? ? Bitmap bitmap=null;

? ? ? ? ? ? try {

? ? ? ? ? ? ? ? connection=new URL(url).openConnection();

? ? ? ? ? ? ? ? is=connection.getInputStream();

? ? ? ? ? ? ? ? bis=new BufferedInputStream(is);

? ? ? ? ? ? ? ? bitmap= BitmapFactory.decodeStream(bis);

? ? ? ? ? ? ? ? is.close();

? ? ? ? ? ? ? ? bis.close();

? ? ? ? ? ? } catch (IOException e) {

? ? ? ? ? ? ? ? e.printStackTrace();

? ? ? ? ? ? }

? ? ? ? ? ? return bitmap;

? ? ? ? }

? ? }

}


0 回復(fù) 有任何疑惑可以回復(fù)我~
#1

qq_極愛自己_0 提問者

萬分感覺?。(∩_∩)O~
2016-01-30 回復(fù) 有任何疑惑可以回復(fù)我~

舉報

0/150
提交
取消
Android必學(xué)-AsyncTask基礎(chǔ)
  • 參與學(xué)習(xí)       40898    人
  • 解答問題       111    個

了解Android中AsyncTask的使用方法,掌握異步線程的使用

進入課程
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號