imagebutton

Image button on visual studio 2010

拥有回忆 提交于 2020-01-04 11:42:45
问题 I am trying to create a button with image and no text from the [Design] view on Visual Studio 2010. I drag & dropped the button, then I click the Image Property, I select a png image from my resource file, but the property always remain empty and the button doesn't have image neither on the [Design] view or in the compiled program. I tried setting the image on the Form.Designer.cs file with: // // button1 // this.button1.Location = new System.Drawing.Point(73, 11); this.button1.Name =

How to switch button image from on to off and vice versa upon click?

拜拜、爱过 提交于 2020-01-02 08:14:19
问题 I have been trying to switch the state of my buttons from on to off and vice versa, by adding an image for on and adding an image for off state. I tried through xml, however I was just able to temporarily switch it upon click (by using press/focus etc). Here is the code for the same: fragment_justin: <RelativeLayout android:id="@+id/top_bar_container" android:layout_width="match_parent" android:layout_height="48.5dp" android:layout_alignParentTop="true" android:background="@color/background

How would I set an ImageButton to change only when my finger is touching it

佐手、 提交于 2020-01-02 06:57:13
问题 I want to create an event to change what my image button looks like, but only when it is being pushed down. So far I have been using an onTouch listener, but that just changes it permanently. I can't find anything like an onKyeUpListener() type of thing for the button. Does anything like this exist? SOLVED final ImageButton button = (ImageButton) findViewById(R.id.ImageButton01); button.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event)

Android widget ImageButton loses image when screen is rotated

佐手、 提交于 2020-01-02 05:25:07
问题 I have a widget on my home screen with several ImageButtons which have default background images. Through the configuration activity, I can change the image on any of the ImageButtons. The problem is that when the screen is rotated, the image on the ImageButton disapears and it changes back to the default image. I don't know why this happens or how to fix it 回答1: When the screen is rotated the entire appwidget is rebuilt using the last RemoteViews object you passed to AppWidgetManager

selected Image button changes its position in recyclerView when scrolling

安稳与你 提交于 2019-12-31 02:55:15
问题 i have a recyclerview in my MainActivity and i'm showing no of items in list manner through RecyclerView.Adapter . here is my recyclerview_list_items.xml file, <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:padding="10dp"> <ImageView android:id="@+id/person_photo" android:layout_width="50dp" android:layout_height=

ListView + ImageButton + descendantFocusability

安稳与你 提交于 2019-12-29 10:05:43
问题 I have a listview to which I add rows with 1 imagebutton .. I tried to set the imagebutton the setfocusable false but still not working .. item_list.xml <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="160dp" android:descendantFocusability="blocksDescendants" android:id="@+id/RL_item"> <ImageButton android:layout_width="200dp" android:layout_height="fill_parent" android

ListView + ImageButton + descendantFocusability

半世苍凉 提交于 2019-12-29 10:03:30
问题 I have a listview to which I add rows with 1 imagebutton .. I tried to set the imagebutton the setfocusable false but still not working .. item_list.xml <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="160dp" android:descendantFocusability="blocksDescendants" android:id="@+id/RL_item"> <ImageButton android:layout_width="200dp" android:layout_height="fill_parent" android

Android ImageButton - determine what resource is currently set

北慕城南 提交于 2019-12-29 07:31:57
问题 Is there a way I can find what resource a particular ImageButton is set to, at any given time? For eg: I have an ImageButton that I set to R.drawable.btn_on onCreate. Later, at some point, the ImageButton gets set to R.drawable.btn_off . I want to be able to check what resource the ImageButton is set to in my code. Thanks Chris 回答1: Just use setTag() and getTag() to associate and retrieve custom data for your ImageView . 回答2: You could define your own class as a child of ImageButton , add a

Error : <item> tag requires a 'drawable' attribute or child tag defining a drawable

点点圈 提交于 2019-12-28 05:48:19
问题 I created a state-list selector file item_bg_selector.xml in the drawable folder like this : <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_selected="true" android:drawable="@drawable/item_background_selected" /> <item android:state_focused="true" android:drawable="@drawable/item_background_selected" /> <item android:state_pressed="true" android:drawable="@drawable/item_background_selected" /> <item android:drawable="@android:color/transparent"/> <

How to open facebook profile/page from ImageButton (Android)

落爺英雄遲暮 提交于 2019-12-25 14:58:30
问题 I'm new to android development I developing a new app with imagebutton to facebook profile/page I tried this code but this code open the facebook in the browser public class AboutActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_about); ImageButton f = (ImageButton)findViewById(R.id.f_logo); f.setOnClickListener(new OnClickListener() { public void onClick(View arg0) { Intent