Example in the use of Android Widget

2010-08-23  来源:本站原创  分类:Mobile  人气:296 

Example in the use of Android Widget

Written before redraw the background by the way, to achieve the object moving. Going to talk today is
How to move the widget, view and other controls to achieve part of the redraw. Before combining hair Droiddraw tools, AbsoluteLayout, free to place the control in any position.
package com.sky;

import android.app.Activity;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AbsoluteLayout;
import android.widget.Button;

@ SuppressWarnings ("deprecation")
public class AbosoluteMove extends Activity implements OnClickListener
(
/ ** Called when the activity is first created. * /
public Button button1;
public Button button2;
public Button button3;
public Button button4;
Button tmp; / / temporary save, select the BUTTON
int x;
int y;
int flag; / / used to select which logo BUTTON
@ Override
public void onCreate (Bundle savedInstanceState)
(
super.onCreate (savedInstanceState);
setContentView (R.layout.main);
button1 = (Button) findViewById (R.id.widget27);
button2 = (Button) findViewById (R.id.widget28);
button3 = (Button) findViewById (R.id.widget29);
button4 = (Button) findViewById (R.id.widget30);
button1.setOnClickListener (this);
button2.setOnClickListener (this);
button3.setOnClickListener (this);
button4.setOnClickListener (this);
)
@ Override
public void onClick (View v)
(
/ / TODO Auto-generated method stub
switch (v.getId ())
(
case R.id.widget27:
flag = R.id.widget27;
setTitle ("button1");
break;
case R.id.widget28:
flag = R.id.widget28;
setTitle ("button2");
break;
case R.id.widget29:
flag = R.id.widget29;
setTitle ("button3");
break;
case R.id.widget30:
flag = R.id.widget30;
setTitle ("button4");
break;
)
)

@ Override
public boolean onKeyDown (int keyCode, KeyEvent event)
(
/ / TODO Auto-generated method stub
return super.onKeyDown (keyCode, event);
)
@ Override
public boolean onTouchEvent (MotionEvent event)
(
/ / TODO Auto-generated method stub
x = (int) event.getX ();
y = (int) event.getY ();
tmp = (Button) findViewById (flag); / / Get the selected BUTTON
AbsoluteLayout.LayoutParams params1 = new AbsoluteLayout.LayoutParams (50,50, x-25, y-50);
tmp.setLayoutParams (params1); / / Set the new location BUTTON
switch (event.getAction ())
(
case MotionEvent.ACTION_DOWN:
tmp.invalidate ();
tmp.setText ("select down");
break;
case MotionEvent.ACTION_UP:
tmp.invalidate ();
tmp.setText ("select UP");
break;
case MotionEvent.ACTION_MOVE:
tmp.invalidate ();
tmp.setText ("Select the move");
break;
)
return super.onTouchEvent (event);
)
)

相关文章
  • Example in the use of Android Widget 2010-08-23

    Example in the use of Android Widget Written before redraw the background by the way, to achieve the object moving. Going to talk today is How to move the widget, view and other controls to achieve part of the redraw. Before combining hair Droiddraw

  • [Android Development] android.widget Collection (Part One) 2010-12-02

    [Android Development] android.widget 20 in one (top 1).

  • Android Widget development guidance 2010-12-02

    Widget is a new feature of Android 1.5, an application to display some common and important information in the user's Home screen (the desktop main screen), the standard Android system image contains some examples of widgets include pointers clock, m

  • Android Widget程序源码 2013-01-22

    一个Android Widget程序的源码,可以在桌面上创建快捷拨号的Widget. 转载:http://www.adobex.com/android/source/details/00000053.htm

  • Android Widget 电池插件的开发实现 带源码 2013-01-24

    看到一篇帖子讲了Android Widget 电池插件的开发实现 但是没贴源码 现在给出 原帖如下: 最近突发奇想,想自己编一个Android电池插件放在桌面上,一是这个App确实有它的实用价值,二是编起来工程量应该不是很大,不用花太长时间,三来又能学习下Widget的开发方法,一举三得,于是,暂停下游戏开发的学习,来编一个widget先. 在查找并结合多方资料后终于实现,效果图如下: 长按桌面空白处,出现菜单,点击Widgets,此时的插件已经装入: 在电源连接时,机器人周围会星光闪闪,表明正

  • Android Widget Development Process 2010-07-21

    1.Widget concept widget is displayed in the Home Screen components, it is just a View, so you can use xml to design the layout. You can design one in the background of the Service, it time to Update this Widget. In addition, the design of the screen

  • Android Widget Development Templates 2010-12-24

    Android uses the Java Widget on language development than the W3C's Widget to improve the efficiency of a lot more things you can do call the system API, in addition to the restrictions on the UI, we can consider some of the help system perfect appWi

  • [Android widget] Activity通过bindService启动Service... 2013-07-09

    Notification就是在桌面的状态通知栏.这主要涉及三个主要类: Notification:设置通知的各个属性. NotificationManager:负责发送通知和取消通知 Notification.Builder:Notification内之类,创建Notification对象.非常方便的控制所有的flags,同时构建Notification的风格. 主要作用: 1.创建一个状态条图标. 2.在扩展的状态条窗口中显示额外的信息(和启动一个Intent). 3.闪灯或LED. 4.电话

  • Android Desktop Components [app widget] Advanced item - feel Recorder 2010-09-08

    This complete the project name: [mood] Recorder Information can be recorded in your mind and use the desktop components in the form displayed on the desktop, and a rich choice of expression and load the desktop, this feature is similar to QQ on the n

  • Android desktop, the infinite potential Widget 2010-12-02

    Android Widget Development Android 1.5 SDK recently added a number of development frameworks, AppWidget framework can be easily developed on the Android desktop, Widget widget, in the past we have seen in a Live Folder, the following example to do a

  • android实现widget时钟示例分享 2014-09-01

    这篇文章主要介绍了android实现widget时钟示例,需要的朋友可以参考下 一.在 AndroidManifest.xml文件中配置Widgets: <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.widget" android:versionCode="1" android:versionName=&qu

  • android之App Widget开发实例 2012-03-20

    前面一节已经实现了一个简单的App Widget,这里将通过一个实例继续深入学习App Widget. 首先继续了解下App Widget框架的主要的类: AppWidgetProvider:继承自BroadcastReceiver,在App Widget应用update,enable,disable和deleted时接受通知.其中onUpdate,onReceive是最常用到的方法. AppWidgetProviderInfo:描述AppWidget的大小,更新频率和初始界面等信息,以xml文

  • Android 桌面组件[widget]初探 2012-08-29

    下面是本篇的大纲: * 1.AppWidget 框架类 * 2.在 Android 如何使用 Widget * 3.AppWidget 框架的主要类介绍 * 4.DEMO 讲解 1.AppWidget 框架类 * 1.AppWidgetProvider :继承自 BroadcastRecevier , 在AppWidget 应用 update.enable.disable 和 delete 时接收通知.其中,onUpdate.onReceive 是最常用到的方法,它们接收更新通知. * 2. A

  • Android之Widget 2013-04-22

    简介 1 Android widget Android widget 也称为桌面插件,其是android系统应用开发层面的一部分,但是又有特殊用途,而且会成为整个android系统的亮点.Android中的AppWidget与google widget和中移动的widget并不是一个概念,这里的AppWidget只是把一个进程的控件嵌入到别外一个进程的窗口里的一种方法. 2 AppWidget Framework 2.1 定义 Android系统增加了AppWidget 框架,用以支持widge

  • android.support.v4.widget.DrawerLayout 抽屉效果导航菜单 2014-12-03

    抽屉效果导航菜单图示 如图所示,抽屉效果的导航菜单不用切换到另一个页面,也不用去按菜单的硬件按钮,直接在界面左上角的一个按钮点击,菜单就滑出来,而且感觉能放很多东西 概况:实现上图所示的抽屉效果的导航菜单有以下两种方式 方式1.用SlidingDrawer: http://developer.android.com/reference/android/widget/SlidingDrawer.html 但是不知道为什么这个类官方不建议再继续用了: Deprecated since API lev

  • Department of famous Gate Android (6) - Controls (View) 2010-03-29

    Department of famous Gate Android (6) - Controls (View) of the DatePicker, TimePicker, ToggleButton, EditText, ProgressBar, SeekBar, AutoCompleteTextView, MultiAutoCompleteTextView Author: webabcd Android describes the use of various controls (View)

  • Department of famous Gate Android (7) - Controls (View) 2010-03-29

    Department of famous Gate Android (7) - Control (View) of the ZoomControls, Include, VideoView, WebView, RatingBar, Tab, Spinner, Chronometer, ScrollView Author: webabcd Android describes the use of various controls (View) ZoomControls - Zoom in / ou

  • Department of famous Gate Android (8) 2010-03-29

    Department of famous Gate Android (8) - Control (View) of the TextSwitcher, Gallery, ImageSwitcher, GridView, ListView, ExpandableList Author: webabcd Android describes the use of various controls (View) TextSwitcher - Text converter control (to chan

  • Department of famous Gate Android (9) - Database support (SQLite), 2010-03-29

    Department of famous Gate Android (9) - Database support (SQLite), the content provider (ContentProvider) Author: webabcd Android describes the use of SQLite, ContentProvider Database support (SQLite) - Android development platform provides the opera

  • Department of famous Gate Android (10) - HTTP communication, XML parsing, through asynchronous message processing Hander 2010-03-29

    Department of famous Gate Android (10) - HTTP communication, XML parsing, through asynchronous message processing Hander Author: webabcd Describes the Android do with the server-side HTTP communication, parsing XML, asynchronous message processing th