android-button

how could find out the end of text position in textview?

风格不统一 提交于 2019-12-22 21:59:10
问题 after asking a question about Place Button just after end of TextView in multilline TextView I give no answer but I think if find the position of end character of final line of textview , then my problem is solved . so how could find out the end of text position in last line of textview? tank's for your help and your attention. 回答1: CharSequence cs = textView.getText(); int position = cs.charAt(cs.length()-1); 来源: https://stackoverflow.com/questions/17306961/how-could-find-out-the-end-of-text

Overriding lock/power button in android devices

℡╲_俬逩灬. 提交于 2019-12-22 19:15:32
问题 I would like to know if its possible to override power button in android? I read a lot of posts in Stack Overflow, some saying it's possible and some saying it's not (example). What I am trying to achieve is that - when user is using my app he needs to press the lock/power button 5 times to lock the screen. I dont want to override the swtich off functionality only the lock one. Is there anyway to fetch power button callback? I tried WakeLock and disabled the keyguard but it does'nt serve my

OnClickListener() must override a superclass method?

大憨熊 提交于 2019-12-22 04:07:31
问题 With this code: import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; . . . Button buttonAuthorizeUsers = (Button) findViewById(R.id.buttonAuthorizeUsers); buttonAuthorizeUsers.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent configure = new Intent(OnDemandAndAutomatic_Activity.this, Configure_Activity.class);

OnClickListener() must override a superclass method?

倖福魔咒の 提交于 2019-12-22 04:07:14
问题 With this code: import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; . . . Button buttonAuthorizeUsers = (Button) findViewById(R.id.buttonAuthorizeUsers); buttonAuthorizeUsers.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent configure = new Intent(OnDemandAndAutomatic_Activity.this, Configure_Activity.class);

Setting Button text font in android

雨燕双飞 提交于 2019-12-22 01:54:03
问题 I have a button created using android widgets. I want to set the font of the button text to Helv Neue 67 Med Cond . How to get this font and set it to the button text in android layout file? 回答1: First you have to put the ttf file in assets folder and then You can use the below code to set Custom font in TextView, same way you can do for Button: TextView txt = (TextView) findViewById(R.id.custom_font); Typeface font = Typeface.createFromAsset(getAssets(), "Helv Neue 67 Med Cond.ttf"); txt

ImageView selectableItemBackgroundBorderless does not render outside of view bounds

孤人 提交于 2019-12-21 09:06:26
问题 I am using selectableItemBackgroundBorderless to add a ripple to an ImageView . My expected behaviour would be to have a circular ripple, extending the views size. Unfortunately the ripple gets cropped by the view bounds. How can this issue be solved? Default state: Pressed state: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/nav_instruction_container" android:layout_width="match_parent" xmlns:app="http://schemas.android.com/apk/res-auto" android

How to rotate views on orientation change without recreating layout?

我的梦境 提交于 2019-12-20 09:18:35
问题 This question has been asked before here but its answer is incorrect. I would like to rotate some views on screen orientation change, but I want to keep the layout unchanged. They should be rotated 90, 180, 270 or 360 degrees according to the current orientation ( SCREEN_ORIENTATION_LANDSCAPE , SCREEN_ORIENTATION_PORTRAIT , SCREEN_ORIENTATION_REVERSE_LANDSCAPE , SCREEN_ORIENTATION_REVERSE_PORTRAIT ). This is what I want to achieve: The answer in the link I mentioned stated that I should

how to make a capsule shape Button in android?

江枫思渺然 提交于 2019-12-20 08:57:31
问题 I want to make a button exactly like in this image I want to use a xml file that will used to produce such button. Can anyone tell me how to do that? 回答1: finally I found the way to do it with xml file. here is the code of the xml file that gave me the capsule shape button. <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" > <corners android:bottomLeftRadius="30dp" android:bottomRightRadius="30dp" android:radius=

Custom info window for google maps android

孤街浪徒 提交于 2019-12-20 05:14:06
问题 I want to have a custom info window appear on marker click. I want it to be something like this: ImageView TextView TextView TextView Button Button I saw other's post question on this, but it's still confusing. 回答1: About ImageView and TextView, try this: set an infowindow layout: infowindowlayout.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" android

java.lang.IllegalStateException: cannot find button's onClick method in Android Studio

被刻印的时光 ゝ 提交于 2019-12-19 07:23:27
问题 I am building an app named Ping in Android Studio. So far my activities are LoginActivity ProfileActivity and Timeline. My issue is that a button in the layout corresponding to the Timeline activity has an onClick method that isn't working. When the button is clicked, the emulator gives the "Unfortunatley, Ping has stopped." I'm defining the buttons and onClick methods the same way I have for other buttons whose functions are working, just this one does not seem to work. I'm receiving an