如何创建没有Android SDK Android小工具? [英] How to create Android widget without android SDK?

查看:169
本文介绍了如何创建没有Android SDK Android小工具?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎样才能创建一个没有使用Android SDK的Andr​​oid小工具?我想,只有Java和Android SDK的创造,但它坠毁。

AndroidManifest.xml中:

 <清单的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
包=com.durden.telecomwidget
安卓版code =1
机器人:=的versionName1.0><采用-SDK安卓的minSdkVersion =14机器人:targetSdkVersion =15/><应用机器人:标签=@字符串/ APP_NAME
    机器人:图标=@绘制/ ic_launcher
    机器人:主题=@风格/ AppTheme>    < reciever机器人:名字=TelecomBalance>
        &所述;意图滤光器>
            <作用机器人:名字=android.appwidget.action.APPWIDGET_UPDATE>< /作用>
        &所述; /意图滤光器>
        <元数据机器人:名字=android.appwidget.provider
            机器人:资源=@ XML / widgetinfo/>
    < / reciever>
< /用途>

widgetinfo.xml:

 < appwidget提供商的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
安卓了minWidth =294dp
安卓了minHeight =72dp
机器人:updatePeriodMillis =86400000
机器人:initialLayout =@布局/主
机器人:配置=com.example.android.ExampleAppWidgetConfigure
机器人:resizeMode =横|纵>

@布局/ main.xml中:

 <?XML版本=1.0编码=UTF-8&GT?;
< LinearLayout中的xmlns:机器人=schemas.android.com/apk/res/android
        机器人:layout_width =FILL_PARENT
        机器人:方向=垂直
        机器人:背景=@机器人:彩色/白
        机器人:layout_gravity =中心
        机器人:layout_height =WRAP_CONTENT>< TextView的机器人:ID =@ + ID / widget_textview
                机器人:文字=你好小工具
                机器人:layout_height =WRAP_CONTENT
                机器人:layout_width =WRAP_CONTENT
                机器人:layout_gravity =CENTER_HORIZONTAL |中心
                机器人:文字颜色=@机器人:彩色/黑白/>
< / LinearLayout中>


解决方案

我没有给你一个明确的答案,你的问题是相当模糊的,首先,但我可以为您指出我认为将是有益的方向:阅读源,卢克,<一个href=\"http://grep$c$c.com/file/repository.grep$c$c.com/java/ext/com.google.android/android/4.0.1_r1/android/widget/TextView.java#TextView.onDraw%28android.graphics.Canvas%29\"相对=nofollow>这里是的方式,在SDK绘制的TextView 。它会给你洞察到你需要做什么。

How can I create an Android widget without using the Android SDK? I tried creating it with only Java and the Android sdk, but it crashed.

AndroidManifest.xml:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.durden.telecomwidget"
android:versionCode="1"
android:versionName="1.0">

<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="15" />

<application android:label="@string/app_name"
    android:icon="@drawable/ic_launcher"
    android:theme="@style/AppTheme">

    <reciever android:name="TelecomBalance">
        <intent-filter>
            <action android:name="android.appwidget.action.APPWIDGET_UPDATE"></action>
        </intent-filter>
        <meta-data android:name="android.appwidget.provider"
            android:resource="@xml/widgetinfo" />
    </reciever>
</application>

widgetinfo.xml:

<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
android:minWidth="294dp"
android:minHeight="72dp"
android:updatePeriodMillis="86400000"
android:initialLayout="@layout/main"
android:configure="com.example.android.ExampleAppWidgetConfigure" 
android:resizeMode="horizontal|vertical">

@layout/main.xml:

    <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:orientation="vertical"
        android:background="@android:color/white"
        android:layout_gravity="center"
        android:layout_height="wrap_content">

<TextView android:id="@+id/widget_textview"
                android:text="Hello Widget"
                android:layout_height="wrap_content"
                android:layout_width="wrap_content"
                android:layout_gravity="center_horizontal|center"
                android:textColor="@android:color/black"/>
</LinearLayout>

解决方案

I don't have a specific answer for you, your question is rather vague to begin with, but I can point you in a direction I think will be helpful: Read the source, Luke, Here is the way that the SDK draws a TextView. It will give you insight into what you need to do.

这篇关于如何创建没有Android SDK Android小工具?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆