android-widget

Start intent from Android Widget on click

北城余情 提交于 2019-12-11 19:52:49
问题 i can update a widget but i have some troubles starting a new intent on click from the widget. This is the code: try { remoteViews.setOnClickPendingIntent(R.id.widgetIcon, openGooglePlay(context, bundle)); } catch (NullPointerException e) { Log.d(TAG, "Error loading google play from widget: " + e.getMessage()); } I am confused why this intent is not started on click. It should be attached to resource widgetIcon only and so not be confused with anything else, right? 回答1: Make sure the

Widget stops working atfter I close my app

余生颓废 提交于 2019-12-11 18:58:23
问题 I have a widget from my app that initially makes a POST request and gets some info in an array and displays them on the widget. It has two buttons for going next and previous on this information and it works perfectly when i build the App. Problem is the moment i close the app the widget stops working, the buttons do nothing. I have no idea what to do. As long as i keep my app opened the app works perfectly but i want it to work even when the app is closed. How can I do that ? 回答1: You could

AppWidget Screen Orientation

你离开我真会死。 提交于 2019-12-11 18:51:39
问题 Here is my question. I have an appwidget which works perfectly in a portrait screen orientation. However, When i changed my screen orientation to landscape my appWidget's width and height changing automatically by the home screen launcher and the problem is in landscape mode my widget's height is not set properly by the homescreen launcher. So, I need to detect is screen orientation changed and re-size my appwidget. I've googled it but still i don't have any idea how can i do that. If it was

Play Sound on Tab Click

若如初见. 提交于 2019-12-11 18:19:15
问题 On an Android phone from AT&T, you can hear a click sound when navigating through tabs. How do I get the Tab widget to play a sound on the click of a tab? tabHost.setOnTabChangedListener(new OnTabChangeListener() { @Override public void onTabChanged(String tabId) { //PLAY SOUND HERE MediaPlayer tabClick = MediaPlayer.create(TabBarActivity.this, R.Raw.gling_click); tabClick.start(); } )}; 回答1: step 1 from the tutorial is this: for(int i=0;i<tabHost.getTabWidget().getChildCount();i++) { tabHost

Dynamically changing the position of a button with respect to another button

一笑奈何 提交于 2019-12-11 18:08:38
问题 I had seen a couple of examples for setting the relative position through program (from java) for views in android. But in my particular case i have 2 buttons (which are not views) say "button_tag" and "button_rate" which are made via xml and are arranged such as "button_tag" above "button_rate" by default. If at any point of time is there a mechanism by which i can make "button_tag" below "button_rate" dynamically. <Button android:id="@+id/button_tag" android:layout_width="match_parent"

Flip a view in ViewPager

为君一笑 提交于 2019-12-11 18:06:37
问题 Is it possible to flip a view in ViewPager.Basically i want to put several views as in hompage and a view behind every view i.e user must be able to flip the view too. 回答1: Yes Very Much Possible. You need Rotation Animation Look here How to make a smooth image rotation in Android? and http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/animation/Rotate3dAnimation.html I used the above and implemented successfully what you are asking. Look for its example in

TextWatcher&Editable cannot be resolved to a type--from “Learning Android”

无人久伴 提交于 2019-12-11 15:38:23
问题 I am reading the book "Learning Android", I typed the code on page 71, the eclipse show the error: Editable cannot be resolved to a type... TextWatcher cannot be resolved to a type... The method addTextChangedListener(TextWatcher) in the type TextView is not applicable for the arguments ... I have checked the code between my eclipse and the book for several times, but I can't find the difference between them. I am a newbie of android, any help will be appreciated. My code is: package com

TextView not displaying data from xml file

那年仲夏 提交于 2019-12-11 15:24:52
问题 Merged with Need help in reading an xml file. I am trying to retrieve some data from my xml file. Below is the code which should be working but in this case it doesn't. I am not getting errors but data just doesn't gets displayed.Please review this code and tell me what's wrong here. (I am trying to look at an id, if it matches a certain digit than display text) Thanks. String stringXmlContent; try { stringXmlContent = getEventsFromAnXML(this); tv.setText(stringXmlContent); } catch

Android - Communications between a widget and its app

点点圈 提交于 2019-12-11 15:09:22
问题 I have a widget that shows various images with text below, and the same UI set up in the app itself. I want the widget to not only be able to open the app, but to open the app based on which picture is showing in the widget and then show that same image in the app. However, I am having a tough time getting this to work. Thanks. 回答1: Let's say there are several images in the ui, you can set different Intent for each image, and these intents each will target a different activity. This post:

How to add Color Picker in Application?

谁都会走 提交于 2019-12-11 14:28:00
问题 I have developed an Application , which uses screen as a Slate and finger as a Chalk, which is working properly. But I want to use different color types for chalk. Here is my Code: MyDemo.java package com.example.mydemo; import android.os.Bundle; import android.app.Activity; import android.view.View; import android.widget.Button; import android.widget.LinearLayout; public class MyDemo extends Activity { private LinearLayout root; private Button btnReset; @Override public void onCreate(Bundle