android 获取图库中展示到界面中
layout:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.example.useimage.MainActivity" > <Button
android:onClick="selectImage"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="选择一个图片" /> <ImageView
android:id="@+id/iv"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/> </LinearLayout>
main_activtity
package com.example.useimage; import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.View;
import android.widget.ImageView; public class MainActivity extends ActionBarActivity { private ImageView iv; @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); iv = (ImageView)findViewById(R.id.iv); } public void selectImage(View view)
{ Intent intent = new Intent();
intent.setAction(Intent.ACTION_PICK);
intent.setType("image/*");
startActivityForResult(intent, 0); } @Override
protected void onActivityResult(int arg0, int arg1, Intent data) { if(data!=null)
{ Uri uri = data.getData();
iv.setImageURI(uri);
}
super.onActivityResult(arg0, arg1, data);
} }
android 获取图库中展示到界面中的更多相关文章
- android 获取application和activity下meta-data中的值
meta-data在AndroidManifest中是以键值对的形式存在的,可以将meta-data放在application根节点下,也可以放在某个activity节点下.因为存放的位置不同,因此获 ...
- Android系统编程入门系列之界面Activity交互响应
在上篇文章中已经了解到界面Activity的绘制完全依赖其加载的视图组件View,不仅如此,用户的每次触摸操作都可以在界面Activity内接收并响应,也可以直接传递给其中的某个视图View响应.本文 ...
- 【Android 界面效果30】Android中ImageSwitcher结合Gallery展示SD卡中的资源图片
本文主要是写关于ImageSwitcher结合Gallery组件如何展示SDCard中的资源图片,相信大家都看过API Demo 中也有关于这个例子的,但API Demo 中的例子是展示工程中Draw ...
- 【Android】12.3 在当前Activity中获取另一个Activity的返回值
分类:C#.Android.VS2015: 创建日期:2016-02-23 一.简介 在上一节的示例中,通过StartActivity(Intent)方法启动另一个Activity后,这两个Activ ...
- Android开发之Intent跳转到系统应用中的拨号界面、联系人界面、短信界面
现在开发中的功能需要直接跳转到拨号.联系人.短信界面等等,查找了很多资料,自己整理了一下. 1.跳转到拨号界面,代码如下: 1)直接拨打 Intent intentPhone = new Intent ...
- 在cocos2d-x界面中嵌入Android的WebView
在Cocos2dxActivity.java中, (1) 增加函数onCreateLayout, [java] view plain copy public LinearLayout onCre ...
- Android 获取View在屏幕中的位置【转】
Android 获取View在屏幕中的位置 https://blog.csdn.net/lonely_fireworks/article/details/7849643
- CSS3 页面中展示邮箱列表点击弹出发送邮件界面
CSS3 页面中展示邮箱列表点击弹出发送邮件界面 代码: <!DOCTYPE html> <html> <head> <meta charset=" ...
- jQuery ajax 获取信息展示在“下拉列表”中
<link href="${ctxStatic}/jquery-select2/4.0.3/select2.min.css" rel="stylesheet&quo ...
随机推荐
- python学习笔记五——数据结构
4 . python的数据结构 数据结构是用来存储数据的逻辑结构,合理使用数据结构才能编写出优秀的代码.python提供的几种内置数据结构——元组.列表.字典和序列.内置数据结构是Python语言的精 ...
- 理解 Delphi 的类(十) - 深入方法[17] - 提前声明
//要点17: 如果前面的方法要调用后面的方法, 后面的方法需要提前声明 function MyFunB(x: Integer): Integer; forward; {使用 forward 指示字提 ...
- PHP IF ELSE简化/三元一次式的使用
一般我们会这样写: <? if($_GET['time']==null) { $time = time(); } else { $time = $_GET['time']; } echo $ti ...
- DTD举例二
DTD举例二: <!--hbase语句库约束文件--> <!DOCTYPE hbaseGroup [ <!ELEMENT hbaseGroup (statements*)> ...
- python之tkinter使用-窗口居中显示
# 窗口居中显示 import tkinter as tk def set_win_center(root, curWidth='', curHight=''): ''' 设置窗口大小,并居中显示 : ...
- vander范德蒙德行列式
https://baike.baidu.com/item/%E8%8C%83%E5%BE%B7%E8%92%99%E8%A1%8C%E5%88%97%E5%BC%8F function m=vande ...
- ceph 安装过程
安装依赖: yum install -y yum-utils && yum-config-manager --add-repo https://dl.fedoraproject.org ...
- jQuery筛选总结
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- day11 内置函数
特殊算数运算 计算整数的和 l = [1,2,3,4,5] print(sum(l)) 除法运算,然后取余 在做页面的时候可以根据数据量分页的时候使用 print(divmod(10,3)) # (3 ...
- 自学Zabbix3.11-宏Macros
点击返回:自学Zabbix之路 点击返回:自学Zabbix4.0之路 点击返回:自学zabbix集锦 自学Zabbix3.11-宏Macros zabbix宏变量让zabbix变得更灵活,它根据一系列 ...