android-widget

can't change the textsize of the thumb of SwitchCompat widget

巧了我就是萌 提交于 2019-12-05 03:46:38
I am having a hard time to change the text size of a switch compact thumb. Here's my layout: <android.support.v7.widget.SwitchCompat android:id="@+id/switch_compat2" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="20dp" android:checked="true" android:switchTextAppearance="@style/MyStyle" android:text="SwitchCompat (SDK v7+)" app:showText="true" /> and the style: <style name="MyStyle"> <item name="android:textColor">#229922</item> <item name="android:textSize">10sp</item> </style> yet, no matter what I do on "MyStyle", the switch always look like

“lateinit” or “by lazy” when defining global android.widget var/val

天涯浪子 提交于 2019-12-05 03:42:57
When defining a global android.widget variable, e.g. TextView , is it preferable to use lateinit or by lazy ? I initially thought using by lazy would be preferred as its immutable but I'm not entirely sure. by lazy example: class MainActivity: AppCompatActivity() { val helloWorldTextView by lazy { findViewById(R.id.helloWorldTextView) as TextView } override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) updateTextView(helloWorldTextView) } fun updateTextView(tv: TextView?) { tv?.setText("Hello?") } } lateinit example: class

How to update widget once broadcast intent CONNECTIVITY_CHANGE is received

情到浓时终转凉″ 提交于 2019-12-05 03:15:31
问题 I want to update the widget text and its color whenever Network-packet-data connection changes. Even this widget can enable/disable Network-packet-data. Broadcast receiver for android.net.conn.CONNECTIVITY_CHANGE has been register in Android manifest file and onReceive() is already overridden in AppWidgetProvider class. I am noticing a very strange behavior whenever I enable/disable the connection onReceive() is getting triggered two times. In first instance I receive NetworkInfo object but

Android: Prevent text field pop-up when entering text in a SearchView

拥有回忆 提交于 2019-12-05 02:48:46
问题 Hello Android developers, I've got a problem with the Android SearchView widget. What I'm trying to do is to attach a "live" text filter to my ListView (text input automatically refreshes filter results). It works actually fine and it was no huge effort to get it working on my ListActivity with these lines: private SearchView listFilter; this.listFilter = (SearchView) findViewById(R.id.listFilter); this.listFilter.setOnQueryTextListener(this); this.listFilter.setSubmitButtonEnabled(false);

Write Multiline Text on Button in Android

≯℡__Kan透↙ 提交于 2019-12-05 02:39:57
I want to know, How to write Multiline Text on Button <Button android:id="@+id/button1" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:layout_centerHorizontal="true" android:layout_marginTop="100dp" android:background="@drawable/layout_border" android:text="Hours Mon - sat 5pm" /> I am getting like this:- but required this kind of button:- Edited::-- Now i got something like this, by using answer given by, @Sino K D : but still looking for help, After adding drawable to left side, getting this:- Sino K D Use (new line)

GridView in android widgets

你离开我真会死。 提交于 2019-12-05 02:28:05
问题 I have been trying to implement widget for my application with GridView . I am new to Android Development. I have searched a lot on internet but could not find anything helpful. I am kind of stuck here , as this is not showing anything on my GridView . Any help would be appreciated. Thanks in advance ! This is my Code public class MainActivity extends AppWidgetProvider{ public static final String TOAST_ACTION = "com.example.widgetdevelopment.TOAST_ACTION"; public static final String EXTRA

Get the position of the current image displayed in Gallery

▼魔方 西西 提交于 2019-12-05 02:19:06
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 ! :( gal.setOnItemSelectedListener(new OnItemSelectedListener(){ @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { //Do something with position } }; You get this callback

Debugging Android Widget Code In Eclipse

天涯浪子 提交于 2019-12-05 02:18:07
I am starting with Android programming with the help of Unlocking Android / Manning which came from Santa and is a pretty good book. After running a few little tests and examples, I'm moving towards developing the concepts for my own application. I want my App to execute as a Home Widget and I'm using this example as my model to get started. While I am able to load and run in the Android ADB emulator the code example in the example's Wiktionoary which is a normal Android App. I am not able to run, but only load into the emulator the Widget version of that code named SimpleWiktionary. Am I am

Multiple widget sizes

拟墨画扇 提交于 2019-12-05 02:16:41
问题 I was searching in internet but nothing helps. I want to make second widget, just bigger. Im using service to update my widget so I need to create 2 services (update data in widget by remoteviews etc.) or can I make it easier? When I add medium widget, it shows up te small one but it takes more space (144dp x 72dp) and there is no update. Maybe I should copy whole app classes and modify it, but I think this is stupid solution. I was trying this solutions how to add multiple widgets in one app

textView marquee

怎甘沉沦 提交于 2019-12-05 02:15:12
问题 I want to put a textView in homescreen, and I need the marquee effect public class MainWidget extends AppWidgetProvider { int a; RemoteViews remoteViews; AppWidgetManager appWidgetManager; ComponentName thisWidget; String[] s={"woddfdfdfdfdfdffffffffffffffffffffffffffffffff","dd","ddd","ffff"}; public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) { Timer timer = new Timer(); timer.scheduleAtFixedRate(new WlanTimer(context, appWidgetManager), 100, 50000)