android-widget

Grid view item not hightlight when press

隐身守侯 提交于 2020-03-17 11:31:52
问题 My app has a grid view, By default, Its item does not highlight when I click on it (I don't know why? ). I try to add it a list selector as below, But it does not work too, <GridView android:id="@android:id/list" android:layout_width="fill_parent" android:layout_height="match_parent" android:layout_above="@+id/load_more_process_id" android:layout_alignParentTop="true" android:drawSelectorOnTop="false" android:listSelector="@drawable/grid_selector" > </GridView> Here my selector: <selector

How to apply changes to widget when placing it on the homescreen in onEnabled?

怎甘沉沦 提交于 2020-03-06 02:31:32
问题 When I try to put my weather widget on the homescreen I want to give the user an option of choosing a city at that moment and the widget starts showing the weather for that city. For this I have made use of onEnabled method in Provider class. So what I am doing here is just starting an activity to some preference class where I make use of string array to give the user the option to choose. And then OnSharedPreferenceChangeListener inside onEnabled again I am starting another activity with the

Set Link Clickable in Java-Android

旧街凉风 提交于 2020-02-27 06:21:47
问题 I am designing an App, where there is TextView, and based on some check condition, I want to make links / phone numbers in the TextView clickable in Java side. Can I do this, I don't want to make it clickable by default which is done by setting in xml file android:autoLink="all" What I already tried: Create regular TextView and don't set autoLink="all", TextView myView = (TextView)view.findViewById(R.id.thisIstheTextView); myView .setLinksClickable(true); also tried : myView

Identify triple tap on custom view

£可爱£侵袭症+ 提交于 2020-02-18 05:41:27
问题 I want to draw circle, whenever user taps on a custom view, and based on tap count circle color changes. Single Tap : YELLOW CIRCLE Double Tap : GREEN CIRCLE Triple Tap : RED COLOR Problem is that, i made one custom view that will count tap event based on time, but some time it miss the first tap. which cause the problem in view. Following code shows all my effort to make above custom view. TripleTapView package com.slk.car_rating_app; import java.util.ArrayList; import java.util.Date; import

appWidgetIds and best way to define multiple size (or resizable) widget

落爺英雄遲暮 提交于 2020-02-07 07:14:52
问题 I want to define multiple size widgets I have sees in other questions that a common practice is to define multiple receivers and providers, however in the onUpdate method I have noticed that there is an array named appWidgetIds eg public void onUpdate(Context c, AppWidgetManager appWidgetManager, int[] appWidgetIds) { for (int i = 0; i < appWidgetIds.length; i++) { ..... .... } } so I'm wondering what is the purpose of this array and if could be used for define multiple size widget without

Set child layout width programmatically In ANDROID?

为君一笑 提交于 2020-02-03 03:42:27
问题 In my Code I have a XML file having multiple child layouts. Aand I just want to set one of these child layout's width programmatically according to device's screen width. till now I had tried Layout params, setparam, and other methods but it shows null pointer exception on getting layout id. my parent layout is a Relative Layout, and 1st Child Layout is a Linear Layout("for this layout I need to change width") <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id

How to show different Activities in Fragment implementation?

旧时模样 提交于 2020-02-02 11:06:46
问题 It is my first time using android fragment. I am following this tutorial to implement a fragment. Everything is fine with this tutorial, I successfully get the result like below: In the tutorial, the DetailsFragment simply shows a TextView containing the text of the currently selected item. That's the right part shows just some texts. My question is how to show different activities on the right side instead of text views. What I mean is illustrated in the following image, for example, the

How do I trigger the redraw of a parent View when any of it's children are redrawn?

被刻印的时光 ゝ 提交于 2020-01-31 08:28:46
问题 Background I have written a custom Android View based on a LinearLayout which I have called ReflectingLayout . The idea is fairly simple, to render a reflection effect below any child Views declared within the ReflectingLayout . e.g... I am achieving this by overriding dispatchDraw() in ReflectingLayout as follows: @Override protected void dispatchDraw(Canvas canvas) { Bitmap bitmap = Bitmap.createBitmap(...); Canvas tempCanvas = new Canvas(bitmap); // Draw child views to bitmap using

how to set the simplecursoradapter to a listview in android?

我的未来我决定 提交于 2020-01-30 12:02:30
问题 i have to set the simpleCursorAdapter into a listView. how can i achieve that? thanks. 回答1: This question is a bit vague, so I'm tempted to answer simply: my_list_view.setAdapter(my_cursor_adapter); But there are better explanations and examples in the documentation. Here is one: http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/view/List2.html 回答2: ListView has the method declard as: public void setAdapter (ListAdapter adapter) And the documentation for

what method I must use Instead of findViewById in app widget?

佐手、 提交于 2020-01-30 11:44:26
问题 When I use findViewById() I get an error. What method should I use, instead of findViewById() in my app widget? P.S.: I want to do something like: Button a = (Button) findViewById(R.id.button); in my screen widget 回答1: You don't need a findViewById() in Widget just do this create a static variable, which will be your onClick name tag: private static final String MyOnClick = "Button OnClick"; Set this onClick tag to your view as below: RemoteViews views = new RemoteViews(context.getPackageName