android-widget

Creating Buttons Dynamically, Could I select one and deselect the other buttons?

南笙酒味 提交于 2020-01-01 18:23:07
问题 I'm creating buttons dynamically ... for(int i=0; i<colSize;i++){ final Button btn = new Button(this); btn.setText(SectionName[i]); btn.setTextSize(10); btn.setPadding(8, 3,8, 3); btn.setTextColor(Color.WHITE); btn.setTypeface(Typeface.SERIF, Typeface.BOLD); btn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { //***Every time that I click my button is selected !:) btn.setSelected(true); } }); } But how could I deselect the other buttons that were selected, I

Can I add widgets from installed apps to my application activity

人盡茶涼 提交于 2020-01-01 16:38:09
问题 I am trying develop an android application for a device (device is not a tablet or phone, its a preconfigured android board running Android 4.1.1)and one of the activity need to display a customized dashboard of several types of information as shown below The types of information shown here is preconfigured. Instead of developing all these from scratch, I am planning to install apps that has widgets (like weather and calendar) and include widgets in my Layout. I refered to the below links Add

Android TextView right alignment on a right-to-left device

末鹿安然 提交于 2020-01-01 12:04:08
问题 I am writing an app that displays in the Hebrew language and for that I am right aligning TextView's text. While developing on a Nexus device all works great and texts are displayed as it should, using the android:gravity="right" for TextView. When I am running the same app on a local mobile carrier device (Israel) which is running a custom ROM all TextView widgets that were set with gravity="right" are appearing as if they were set as gravity="left". If I go and change the gravity to left

how can we make table layout to scroll both ways ( horizontally, vertically)

放肆的年华 提交于 2020-01-01 10:52:13
问题 I am having a table defined in XML file, which currently set to Scroll vertically. But i also want it scroll horizontally as required. Here is the code of XML in use <?xml version="1.0" encoding="utf-8"?> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:scrollbars="vertical" android:layout_height="fill_parent" android:layout_width="fill_parent"> <TableLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android

getting battery level at android widget

若如初见. 提交于 2020-01-01 08:56:28
问题 I wrote a widget for Android and I'm trying to get the battery level. I've tried using Intent batteryIntent = context.registerReceiver(null, new IntentFilter(Intent.ACTION_BATTERY_CHANGED)); but I get the error: "IntentReceiver components are not allowed to register to receive intents" Why? the ACTION_BATTERY_CHANGED is a sticky intent and I don't register a receiver (null in the first parameter). Any workaround? Thanks. 回答1: hackbod gave the solution at the comments: " use

android:errorMessageBackground getting no resource found error in styles.xml

ぐ巨炮叔叔 提交于 2020-01-01 08:48:49
问题 i was working on EditText validations and using ' setError ' to show error messages. My primary motto is to change the error popup as par my application design. I used the "android:errorMessageBackground" in styles but unfortunately i am getting **No Resource found error** . Used Base API: 2.2 (Even tried with 4.0.3 also) not sure what we need to do ? 回答1: This seems to be a known issue: https://code.google.com/p/android/issues/detail?id=55879 来源: https://stackoverflow.com/questions/13874197

Example of custom setDropDownViewResource spinner item

荒凉一梦 提交于 2020-01-01 04:26:33
问题 I would like to display two values in an drop down view of my spinner. Currently, it only has a city name, but I would also like to add a small distance field to it. MyCity<MyCityDistance> dataAdapter; dataAdapter = new MyCity(this, R.layout.mycityrow, list); dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); I have all the code for custom data adapter, exapanding my view and holder etc. However, the item which gets show doesn't display both the city and its

What is the best way to update android widget on screen_on. Is it supported in Android Oreo (API 26)

别等时光非礼了梦想. 提交于 2020-01-01 03:20:35
问题 I created a widget, which was working quite fine, and then I changed targetSDK from 23 to 26, due to the requirement from Google Play Developer Console. After switching to Android SDK 26, my app widget is no more updating on the screen_on/User_present event. I can see that there are a bunch of changes in Android 26 for background running task due to (Background Execution Limits). Following are my questions? Q1- How can I update my app widget on every screen_on event, so that the user will see

How to get selected text from edittext in android?

江枫思渺然 提交于 2020-01-01 02:41:33
问题 I have a edittext in which some text are selected . I want to get only selected text from edittext on click of button . Please suggest me usable link or sample code. 回答1: EditText et=(EditText)findViewById(R.id.edit); int startSelection=et.getSelectionStart(); int endSelection=et.getSelectionEnd(); String selectedText = et.getText().toString().substring(startSelection, endSelection); 回答2: getSelectionStart() getSelectionEnd() see this link 来源: https://stackoverflow.com/questions/10070762/how

How to show notification count on app icon like Facebook?

非 Y 不嫁゛ 提交于 2019-12-31 19:28:07
问题 I want to show unread notification count on my app icon when app is not opened. this post seems to be close but it is 3 years old . Has there been any change on this or I should go with solutions provided in the accepted answer? 回答1: Unfortunately you cant achieve this for all android devices. Certain manufacturers (e.g. Samsung or Sony) have included this functionality into their customised Android launchers. Also some 3rd-party launchers (e.g. Nova Launcher) have included an API to