android-view

Add String to ImageView Object Android

女生的网名这么多〃 提交于 2019-12-23 22:00:51
问题 I need to attach a String into the ImageView object so that I could do something like imgView1.getString() and it would return it. I know there is getTags and setTags but from my understanding that just uses ints. Thank you 回答1: Just complementing @dharms answer, you can set any Object as the tag for the ImageView , whether is an int, double, String, etc. So in your case you can do this: imgView1.setTag("some_string") and then to retrieve it just do: String someString = (String) imgView1

Android: Putting a vertical divider/separator line between textviews in a horizontal linear layout nested in vertical linear layout?

怎甘沉沦 提交于 2019-12-23 21:01:12
问题 For an android content view, I have a vertical linearlayout with some textviews that have some lines to divide and separated the vertical elements, this works fine and the xml is below. <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width=

How to get the id of a dynamically created textview?

大兔子大兔子 提交于 2019-12-23 18:36:18
问题 I'm trying to dynamically add and remove TextView for an android app I'm making but I'm running into difficulty setting and getting the TextView's id. I seem to be getting null pointer exception's for the last two lines of code (et.setText and ll.removeView). Does anyone have any suggestions on how I can dynamically set and get the id of a textview? Apparently .setId doesn't seem to work, or more likely, I'm doing it wrong. //surrounding non-relevant code removed EditText et = (EditText) view

Creating transparent circle cutout in a View in Android

半城伤御伤魂 提交于 2019-12-23 18:22:59
问题 I'm trying to create a translucent help overlay to be displayed over my activity's main screen when the user first opens the app. I would like to highlight a button contained in the main layout (and inflated using setContentView), by "cutting out" a section of the overlay which corresponds to the position of the button, and make the cutout transparent. The overlay is a programmatically-created view (which extends RelativeLayout) which is added to my activity's main FrameLayout, like this:

Left margin between icons and NavigationView

怎甘沉沦 提交于 2019-12-23 17:53:18
问题 I have to add a left margin between the icons and the NavigationView , in arrow in the image bellow: I know that according to google specs, this margin must have 16dp but I need to change it. I have tried: <dimen tools:override="true" name="design_navigation_icon_padding">64dp</dimen> <dimen tools:override="true" name="design_navigation_separator_vertical_padding">20dp</dimen> But still not working. Any ideas? 回答1: The xml layout of that item is design_navigation_item.xml <android.support

No View Found for ID when “Don't Keep Activities” Is Turned On

落爺英雄遲暮 提交于 2019-12-23 16:34:30
问题 My app was crashing intermittently after some inactivity. So i figured I wasn't storing things correctly. I turned on "Don't Keep Activities" to troubleshoot and now my app is crashing everywhere. Stack trace: https://gist.github.com/hanleyhansen/6d41fee54b1e129b7922 This is the layout that goes missing: https://gist.github.com/hanleyhansen/73ace0c99ae675023e0f 回答1: I think you are experiencing a likely symptom of Issue 19917. This bug exists in 3.2 and higher and was only fixed recently (4.2

extending android button by using onDraw

孤者浪人 提交于 2019-12-23 13:19:59
问题 I want to change my button shape BUT I WANT TO USE onDaw method and EXTENDING button class. So what I've just done for the beginning is : <view class = "com.example.button.MainActivity$MyButton" android:layout_width="wrap_content" android:layout_height="wrap_content" /> and public static class MyButton extends Button { public MyButton(Context context) { super(context); } public MyButton(Context context, AttributeSet attrs) { super(context, attrs); } public MyButton(Context context,

Set text in TextView in custom dialog

若如初见. 提交于 2019-12-23 12:57:10
问题 I want to set the text in a TextView contained in a custom dialog programmatically, so that I can use Html.fromHtml . In what function should I call setText ? I've tried doing it in onCreateDialog , but this does not actually change the text. public class InfoDialogFragment extends DialogFragment { @Override public Dialog onCreateDialog(Bundle savedInstanceState) { // Use the Builder class for convenient dialog construction AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());

Set text in TextView in custom dialog

前提是你 提交于 2019-12-23 12:56:01
问题 I want to set the text in a TextView contained in a custom dialog programmatically, so that I can use Html.fromHtml . In what function should I call setText ? I've tried doing it in onCreateDialog , but this does not actually change the text. public class InfoDialogFragment extends DialogFragment { @Override public Dialog onCreateDialog(Bundle savedInstanceState) { // Use the Builder class for convenient dialog construction AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());

Can't make a view overlay another view in FrameLayout

无人久伴 提交于 2019-12-23 11:49:11
问题 I want to make my ImageView on top of my Button, but the button will always overlay the ImageView , no matter which layout I choose or the way I arrange my layout... this is an example of a FrameLayout that I tried: EDIT: just for simplifying my question : Why doesn't the FrameLayout work as it should? (you can copy this code to your Android Studio and see yourself) <?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout