AS-demo09
,mainifast: <uses-permission android:name="android.permission.SET_WALLPAPER"/> , <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" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context=".MainActivity"> <TextView
android:id="@+id/title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="长按图片设置为背景"/>
<ImageView
android:id="@+id/img"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/logo"/>
</LinearLayout>
================================ package com.example.demo09longclickchangebg; import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView; import java.io.IOException; public class MainActivity extends Activity { private TextView textView =null;
private ImageView imageView = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); this.textView=(TextView)super.findViewById(R.id.title);
this.imageView=(ImageView)super.findViewById(R.id.img); this.imageView.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View view) {
try {
MainActivity.this.clearWallpaper();
MainActivity.this.setWallpaper(MainActivity.this.imageView.getResources().openRawResource(R.drawable.logo));
MainActivity.this.textView.setText("手机桌面背景已修改BG changed!");
} catch (IOException e) {
MainActivity.this.textView.setText("手机桌面背景修改Error");
}
return false;
}
}); } @Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
} }
AS-demo09的更多相关文章
- NSURLCache
属性介绍: //获取当前应用的缓存管理对象 + (NSURLCache *)sharedURLCache; //设置自定义的NSURLCache作为应用缓存管理对象 + (void)setShared ...
- 群里分享的react的收藏一下!今日周末,改了个表单验证然后无所事事了!
今日周末,改了个表单验证然后无所事事了,然后把昨天群里分享的react的收藏一下尽管现在还在研究angular和nodeJs毕竟刚刚开始用有点不熟...没准以后会研究一下react毕竟看着下面这张图还 ...
- NSURLCache详解和使用
使用缓存的目的是为了使应用程序能更快速的响应用户输入,是程序高效的运行.有时候我们需要将远程web服务器获取的数据缓存起来,以空间换取时间,减少对同一个url多次请求,减轻服务器的压力,优化客户端网络 ...
- React 入门实例教程
现在最热门的前端框架,毫无疑问是 React . 上周,基于 React 的 React Native 发布,结果一天之内,就获得了 5000 颗星,受瞩目程度可见一斑. React 起源于 Face ...
- JDBC详解
一.相关概念 1.什么是JDBC JDBC(Java Data Base Connectivity,java数据库连接)是一种用于执行SQL语句的Java API,可以为多种关系数据库提供统一访问,它 ...
- FMDB 多线程使用
在App中保持一个FMDatabaseQueue的实例,并在所有的线程中都只使用这一个实例. [FMDatabaseQueue databaseQueueWithPath:path]; FMDatab ...
- Facebook React.js库 入门实例教程
作者: 阮一峰 日期: 2015年3月31日 现在最热门的前端框架,毫无疑问是 React . 上周,基于 React 的 React Native 发布,结果一天之内,就获得了 5000 颗星,受瞩 ...
- Hibernate day03笔记
Hibernate的关联关系映射:(多对多) 多对多的配置: 步骤一创建实体和映射: Student: public class Student { private Integer sid ...
- jBox使用方法
1.引入jquery文件 2.引入css和jBox文件 <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml& ...
- Jquery 学习三
一.each语句 1.each语句的功能 在jQuery中,通过$函数获取的都是jQuery对象.通过测试可知,jQuery对象是一个类数组的特殊对象,其是DOM对象的集合.而each语句就是专门用于 ...
随机推荐
- CSS中position属性 (absolute,relative,static,fixed)
只要position的属性值设置的不是默认的值则定位的元素都将脱离文档流 1.static是position的默认的值,按照正常的文档流进行排版,设置了该属性值得元素的top,left属性均不起作用. ...
- 修改Wordpress目录
安装完wordpress,此时访问地址为:http://localhost/wordpress 1.不想让人知道我的文件目录,于是我把原来的wordpress改为w, 2.后台设置 3.WordPre ...
- 集合类(Objective-C & Swift)
内容提要: 本文前两部分讲了Cocoa的集合类和Swift的集合类,其中Cocoa提供的集合类包括NSArray.NSMutableArray.NSDictionary.NSMutableDictio ...
- pod》error:The dependency `` is not used in any concrete target
内容提要: podfile升级之后到最新版本,pod里的内容必须明确指出所用第三方库的target,否则会出现The dependency `` is not used in any concrete ...
- ECSHOP给分类添加图
1.修改/admin/template/category_info.html <tr> <td>{$lang.cat_img}:</td> <td> & ...
- Tea---hdu5881(规律)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5881 题意: 现在有一壶水,体积在[L, R]范围内,现有两个空杯子,现想要把这壶水倒入这两个杯子中去 ...
- Codeforces Round #367 (Div. 2)---水题 | dp | 01字典树
A.Beru-taxi 水题:有一个人站在(sx,sy)的位置,有n辆出租车,正向这个人匀速赶来,每个出租车的位置是(xi, yi) 速度是 Vi;求人最少需要等的时间: 单间循环即可: #inclu ...
- mysql tinyint smallint mediumint int bigint
类型 存储所占空间 (无论显示多少位) (单位 字节/bytes) 存储数据范围 最大显示长度 tinyint 1 -128 ~ 127 signed 0 ...
- A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null. Return a deep copy of the list.
图解: 此题过程分为三个阶段,分别是 1.负责后面一个节点,并且将这个节点插入到原来链表中 2.复制后面一个节点的random指针. 3 拆分组合链表为两部分. 第一部分代码: while(curr ...
- CSS布局一
CSS布局一 实例一(居中) div#container{ width:960px; height:650px; margin:0 auto; border:1px solid #ccc; /*就是说 ...