android ImageView 显示本地图片

android 读取本地图片并显示

MainActivity.java

package com.example.ict.client;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.StrictMode;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.TextView;

import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.Socket;

public class MainActivity extends AppCompatActivity {

    private static final String HOST = "192.168.43.1";
    private static final int PORT = 5555;
    TextView textView = null;
    Socket socket = null;
    private Bitmap bmp = null;
    private ImageView imageView = null;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        if (android.os.Build.VERSION.SDK_INT > 9) {
            StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
            StrictMode.setThreadPolicy(policy);}

        imageView = (ImageView)findViewById(R.id.imageView);
      //  imageView.setImageResource(R.mipmap.ict);
        bmp = getLoacalBitmap("/mnt/sdcard/arrow.png");
        imageView.setImageBitmap(bmp);



        try{
            socket = new Socket(HOST,PORT);
            DataInputStream dataInput = new DataInputStream(socket.getInputStream());
            int size =dataInput.readInt();
            byte[] data = new byte[size];
            int len = 0;
            while(len


    
    
    
    

    




你可能感兴趣的:(android)