android-widget

Android:How to get the text from the Button when clicked? [duplicate]

限于喜欢 提交于 2019-12-06 22:25:19
This question already has answers here : Get text from pressed button (6 answers) Closed 6 years ago . for( i=0; i<26; i++) { btnAlpha[i] = new Button(this); btnAlpha[i].setBackgroundColor(Color.TRANSPARENT); btnAlpha[i].setTextColor(Color.GREEN); btnAlpha[i].setText(Character.toString ((char)(j+i))); btnAlpha[i].setOnClickListener(new View.OnClickListener(){ public void onClick(View v){ //Want to get the text from the current button. btnAlpha[i].getText(); //But it gives error that "i" cannot be accessed. }}); The error i get is "cannot refer to a non-final variable inside an inner class

PendingIntent to launch and stop a Service

谁都会走 提交于 2019-12-06 21:41:19
问题 I'm trying to make a simple widget with a button that start a Service with the OnClickPendingIntent() . I can start it fine but I can't figure out a way to stop it (I know I can do it with a BroadcastReceiver or something similar but I would like to avoid hardcode). This is my code: Intent intent = new Intent(context, myService.class); PendingIntent pendingIntent = PendingIntent.getService(context, 0, intent, 0); RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.my_widget

Get the position of the current image displayed in Gallery

社会主义新天地 提交于 2019-12-06 21:00:04
问题 in my application , i have a gallery of pictures, but i want to detect the position of the current image displayed , For example : when i launch my acvitivity, the position is 0, but when i scroll in my gallery,i want to get The position of the Current image displayed , i have tried OnFocusChanged , OnItemClicked , but that works only if i click on an item of my gallery Any ideas ! :( 回答1: gal.setOnItemSelectedListener(new OnItemSelectedListener(){ @Override public void onItemSelected

EditText on demand widget

主宰稳场 提交于 2019-12-06 19:18:27
I'd like to have a TextView display text, and when you click/longclick on it, a textbox should "show up" and allow editing of said text. When you're done editing (onkey enter i suppose) it should revert back to a textview with the updated text... I'm wondering if it's feasable to implement such a widget or should I hack a workaround? Tips and suggestions are very welcome. If you need further idea of what I mean, just go to your e.g. (windows) skype profile and see for yourself. EDIT: Clarification: I'm specifically asking for a widget or such which is a textview until clicked on, then

Android: How to clear an EditText by cross Button in the right side

守給你的承諾、 提交于 2019-12-06 17:28:57
问题 I have created an EditText for search, which contains on the left side a search icon and on the right side of icon: <EditText android:id="@+id/Search" android:layout_width="250dp" android:layout_height="wrap_content" android:drawableLeft="@android:drawable/ic_menu_search" android:drawableRight="@android:drawable/ic_delete" android:hint="Search Product .." > </EditText> I want to know how can I clear the content of EditText when I click the cross button. Thank you in advance. 回答1: An improved

Layout for TimePicker-based DialogPreference

杀马特。学长 韩版系。学妹 提交于 2019-12-06 17:01:02
问题 I'm writing an app that requires a TimePicker-based preference (two, actually) and I swiped some (Apache-licensed) code from the Android Programming Tutorials book. I've modified it to work a little better, but there's one thing puzzling me. I haven't tried it on an actual device yet but on emulators it now takes into account system settings for 24-hour time display, clears focus on the TimePicker dialog so that the time is read even when edited manually instead of using the arrow keys, and -

App widget with listview

半世苍凉 提交于 2019-12-06 16:40:39
I have some problem. I'm working with Android 2.2 and now I want to create widget with ListView. But after a lot of time as I seeking answer, I was discovered that it's impossible for this version. But maybe anyone know how I can realise similar effect? How I can to realize the effect of scrolling in App Widget in Android 2.2? Thanks in advance. I found solution for this question. I can use android-support library. 来源: https://stackoverflow.com/questions/8846743/app-widget-with-listview

How do I change TextView font style in a Home screen widget?

我们两清 提交于 2019-12-06 15:57:21
How do I change the font style in a TextView in a Home screen widget? If you mean in runtime, a simple way is: Text Size yourRemoteView.setFloat(R.id.textview, "setTextSize", 30); Text Color yourRemoteView.setInt(R.id.textview, "setTextColor", Color.RED); Like this: First, define text styles in values/styles.xml : <resources> <style name="AppTheme" parent="android:style/Theme.Light"> .... </style> <style name="WidgetEntryTitle" parent="style/AppTheme"> <item name="android:textSize">24sp</item> <item name="android:textStyle">bold</item> <item name="android:textColor">@android:color/black</item>

Android pending intent not being called within widget

萝らか妹 提交于 2019-12-06 14:59:36
问题 Like in this question (accepted answer), I'm trying to launch voice recognition from one of my app's widgets. I succesfully managed to open dialog that requests voice input with this code inside onUpdate() method of the Widget: // this intent points to activity that should handle results, doesn't work Intent activityIntent = new Intent(SoulissApp.getAppContext(), WrapperActivity.class ); //doesn't work as well //activityIntent.setComponent(new ComponentName("it.angelic.soulissclient", "it

How can you create a widget inside an android application? (Use App Widget Host class?)

▼魔方 西西 提交于 2019-12-06 14:50:24
问题 I need to create an application that contains multiple widgets. These are not desktop widgets. I need to be able to interact with these widgets as if they were desktop widgets, but they need to be encased inside a larger application. (Each widget has it's own functionality and behavior when clicked.) Is this possible in android? Or do I need to create an application and create each object that I'd like to behave like a widget actually as a view? Ex. The parent app is for a car. Example of "in