android-widget

setTextViewText not updating widget

*爱你&永不变心* 提交于 2019-12-17 20:48:28
问题 Shown below is a simplified version of my class. I am having trouble in the onReceive method which isn't updating the widget TextView. It shows the correct information in the logcat which is outputted on the line before the setTextViewText. I'm not sure whats wrong and have been pulling my hair out (and I'm already balding). public class SnowWidget extends AppWidgetProvider { public static List<Article> mymtns = new ArrayList<Article>(); public static RemoteViews remoteViews; public static

Display HTML Table in webview

淺唱寂寞╮ 提交于 2019-12-17 20:48:27
问题 How to display HTML table with rows and columns in WebView in Android. Give me some example. 回答1: Create an HTML template String myTable = "<table border=1>" + "<tr>" + "<td>row 1, cell 1</td>" + "<td>row 1, cell 2</td>" + "</tr>" + "<tr>" + "<td>row 2, cell 1</td>" + "<td>row 2, cell 2</td>" + "</tr>" + "</table>"; and load into your WebView myWebView.loadDataWithBaseURL(null, myTable, "text/html", "utf-8", null); 回答2: Its also working for me: String tag = "<table border=1>" + "<tr>" + "<td

android.os.NetworkOnMainThreadException

*爱你&永不变心* 提交于 2019-12-17 20:29:45
问题 In my application am getting android.os.NetworkOnMainThreadException . I am trying to get images from url at that time i am getting this Exception . If i run application in 2.2 it is working fine but if i run in 4.0 am getting exception. public static Bitmap getBitmap(String url) { Bitmap bitmap = null; try { // replace space with url encoded character. url = url.replace(" ", "%20"); // System.out.println("url : " + url); URL urll = new URL(url); InputStream in = (InputStream) urll.getContent

Inverted ListView in Android?

折月煮酒 提交于 2019-12-17 20:07:07
问题 Is there an easy way to display a ListView in reverse order? I am trying to create a conversation-based app, and would like the most recent entries to be at the bottom of the ListView. I am aware of transcriptMode and stackFromBottom, however my problem is the order of the data. Say I have 100 conversation items, and want to display items 80-100, with 100 being the most recent conversation item. I would like to show 80-100, which implies an ORDER BY id desc LIMIT 20 in my query, which forces

failed binder transaction on widget update

北城以北 提交于 2019-12-17 19:55:24
问题 i am updating one bitmap in widget (the whole widget is only one ImageView) like this remoteViews.setImageViewBitmap(...) and in some rare situations (it happend 3 times in 6 months of every day use) i get "!!! FAILED BINDER TRANSACTION !!!". then, only phone reboot solves this problem. uninstaling and installing again, does not help, only reboot. i checked the icon's size and it is only 56 kilobytes, so it fits within the IPC memory limit. when i remove setImageViewBitmap(...) the widget

How to change textsize in datepicker?

一个人想着一个人 提交于 2019-12-17 19:38:17
问题 The default textsize in datepicker is too big for my app. I've seen a way suggested to change it here, but fishing around for the textviews nested inside the datepicker class seems clunky and error prone. Is there a better/cleaner way to do it? 回答1: The easiest way to change the font size of datepicker/timepicker/numberpicker is customizing the theme. In styles file, set the default font size in the following way. <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> <!--

How to change textsize in datepicker?

爷,独闯天下 提交于 2019-12-17 19:36:46
问题 The default textsize in datepicker is too big for my app. I've seen a way suggested to change it here, but fishing around for the textviews nested inside the datepicker class seems clunky and error prone. Is there a better/cleaner way to do it? 回答1: The easiest way to change the font size of datepicker/timepicker/numberpicker is customizing the theme. In styles file, set the default font size in the following way. <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> <!--

How to tell which button was clicked in onClick()

南楼画角 提交于 2019-12-17 19:29:51
问题 I have multiple buttons in an Android app. I want to know, in the Java code, which button was clicked. As far as I can tell, this is accomplished with a single method like this: public void onClick(View view) { // Do something } And inside that method, you have to figure out which button was clicked. Is that correct? If so, how do I tell which was clicked? I do have the various Button objects returned by findViewById(). I just don't know how to use them to tell which button was clicked. 回答1:

adding CheckBox to list row loses my onItemClick events?

北城以北 提交于 2019-12-17 18:28:36
问题 I have a ListView with an ArrayList adapter. The rows are not very complex (an Image on the left, a LinearLayout with TextViews inside, and a CheckBox on the right ... the layout is copied in below.) The goal is to have a QuickAction bar come up if the user clicks on the image or text, and have the CheckBox change state if the user clicks on the CheckBox. I have each part working independently, but not when they're together in the layout - somehow, I'm losing the onItemClick event. The

imeOptions “actionNext” programmatically - how to jump to next field?

↘锁芯ラ 提交于 2019-12-17 17:59:26
问题 In layout XML it is possible to specify android:imeOptions="actionNext" which adds Next button in virtual keyboard and by clicking on it - focus jumps to the next field. How to do this programmatically - e.g. based on some event trigger focus to go to the next field? 回答1: You can use the constants from EditorInfo class for the IME options. like, editText.setImeOptions(EditorInfo.IME_ACTION_NEXT); 回答2: Search for the next focusable field and than invoke requestFocus() . TextView nextField =