android-widget

Android how to use/show MediaController with SurfaceView and MediaPlayer for video?

北战南征 提交于 2019-12-31 17:11:10
问题 I have to use MediaPlayer to play a video, NOT a VideoView. I have a SurfaceView in Xml Layout and on the Activity side a MediaPlayer and a MediaController. I coudldn't find a way to use MediaController with SurfaceView and MediaPlayer. It is so easy with VideoView but cant figure out how to use with MediaPlayer. I have found examples online but they are all about playing audio, not video. This is surfaceCreated method where i create the MediaPlayer @Override public void surfaceCreated

how to set width which is equal to another widget on android

老子叫甜甜 提交于 2019-12-31 12:36:33
问题 I need to draw a horizontal line below a text field such that the width of the line equals the text width (not the width of the full screen). In my app I have a textview below a view(Horizontal line). The width of the line view should be equal to the width of the textview . I tried android:layout_width="wrap_content" and "match_parent", which does not solve the problem. This is xml coding sample: ...... <TextView android:id="@+id/textView1" android:layout_width="wrap_content" android:layout

How to set the custom size of the stars in RatingBar

。_饼干妹妹 提交于 2019-12-31 08:57:07
问题 I have already added a style <style name="myRatingBar" parent="@android:style/Widget.RatingBar"> <item name="android:minHeight">32dp</item> <item name="android:maxHeight">32dp</item> </style> However instead of scaled stars I'm receiving cropped stars: Is there a way to change the size of the stars? 回答1: Another approach would be scaling the widget: android:scaleX="0.5" android:scaleY="0.5" 回答2: Android won't scale a rating bar icons. When you decrease the minHeight and maxHeight android will

Android: Custom View with object reference from attrs.xml, always null

梦想与她 提交于 2019-12-31 03:15:51
问题 I'm trying to setup a relationship hierarchy between objects. Every object has a parent of the same type as itself, or null . I have a main.xml that contains some of these: <com.morsetable.MorseKey android:id="@+id/bi" android:layout_weight="1" custom:code=".." custom:parentKey="@id/be" android:text="@string/i" /> a res/values/attrs.xml that contains one of these: <declare-styleable name="MorseKey"> <attr name="code" format="string"/> <attr name="parentKey" format="reference"/> </declare

Programmatically scrolling an EditText

浪子不回头ぞ 提交于 2019-12-30 18:55:33
问题 I'm writing a simple caesar-encryption-activity. Two EditTexts on screen, one clear-text, one crypted. Here's an example for the crypted EditText - the cleartext one is similar. <EditText android:layout_below="@id/Caesar_Label_CryptText" android:layout_height="wrap_content" android:layout_width="fill_parent" android:id="@+id/Caesar_Text_CryptText" android:hint="Enter crypted text" android:maxLines="2" android:lines="2" android:minLines="2" android:inputType="text|textMultiLine

Programmatically scrolling an EditText

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-30 18:55:12
问题 I'm writing a simple caesar-encryption-activity. Two EditTexts on screen, one clear-text, one crypted. Here's an example for the crypted EditText - the cleartext one is similar. <EditText android:layout_below="@id/Caesar_Label_CryptText" android:layout_height="wrap_content" android:layout_width="fill_parent" android:id="@+id/Caesar_Text_CryptText" android:hint="Enter crypted text" android:maxLines="2" android:lines="2" android:minLines="2" android:inputType="text|textMultiLine

Get current onClickListener of an Android View object

為{幸葍}努か 提交于 2019-12-30 18:49:45
问题 I need to get the current onClickListener --and other kind of listeners-- of a View object in order to install a new proxy-onClickListener which will do some work and then forward the call to the original listener. Many thanks!!! 回答1: You just need to be a little creative! Just do something like this: Subclass the View.OnClickListener abstract class ProxyAbleClickListener implements OnClickListener { Runnable ProxyAction; @Override public void onClick(View arg0) { if (ProxyAction != null) {

ListView does not update when calling notifyDataSetChanged from a BaseAdapter

一世执手 提交于 2019-12-30 18:26:29
问题 im am having difficulties to update a ListActivity when the underlying data changes. I am using a custom (list) adapter (CustomListAdapter) derived vom BaseAdapter to fill a ListActivity with custom list elements (CustomListElement). The elements in question can have their underlying data changed over time, either by user interaction or by changes in an underlying database. In order to announce said changes, the CustomListElement and CustomListAdapter objects can register DataSetObserver

ListView does not update when calling notifyDataSetChanged from a BaseAdapter

依然范特西╮ 提交于 2019-12-30 18:26:14
问题 im am having difficulties to update a ListActivity when the underlying data changes. I am using a custom (list) adapter (CustomListAdapter) derived vom BaseAdapter to fill a ListActivity with custom list elements (CustomListElement). The elements in question can have their underlying data changed over time, either by user interaction or by changes in an underlying database. In order to announce said changes, the CustomListElement and CustomListAdapter objects can register DataSetObserver

Android task manager or system dialog

好久不见. 提交于 2019-12-30 13:50:13
问题 I would like to know is there a way to get events while displaying a System dialog (Such task manager, shut down alert,...). I can close the system dialogs from my activity through intent like below Intent closeDialog = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS); sendBroadcast(closeDialog); But in my code I need to know a system dialog is shown over the screen (They can be Task manager/ Shut down dialog ...), so that I can invoke the above code for closing it. I searched for intent