android-edittext

left drawable alignment with text in android

这一生的挚爱 提交于 2019-12-02 01:15:19
I am new to custom view and didn't know much about canvas in android, I wanted to align a left drawable to right side of layout along with the text(whether multiline or not) of same textview as in this image In the above image, i wanted to align $ image along with text($20.0 -$90.0 /hour) and must be in center if text is multiline and i don't want to use any extra layouts. Thanks in advance This is my basic xml, <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="center""> <TextView android:id="@+id/ad_post_tv_noDays" style="@style

“EditText and TextView” formatted with thousands separators (,) in android

末鹿安然 提交于 2019-12-02 01:12:59
I want a thousands separator (,) in EditText when i am typing in editText. after that,i will do some operation on the number.then show the result in the TextView by thousands separator (,). this is my code: public class Mainactivity extends Activity { /** Called when the activity is first created. */ EditText edt; TextView txt; Button btn; OnClickListener myclick = new OnClickListener() { @Override public void onClick(View arg0) { // my calculation double num1 = Double.parseDouble(edt.getText().toString()); double num2 = num1 + 7; txt.setText("" + num2); } }; @Override public void onCreate

Can two views both have focus in Android

穿精又带淫゛_ 提交于 2019-12-02 00:32:30
I have a EditText, and a popupWindown(which has a ListView in it), now i touch the EditText, the popupWindow shows. i need the situation: i can input something in SoftInput, and i also can click a child item in ListView which is the children of PopupWindow. Now, i can only input, or can only click listview , i can't do the both thing in Android 4.1, 4.2. But i can do both in Android 4.4, 5.0。 I tried in many ways, like popupWindo.setFocus(true), which only make the EditText lose the focus. So, Can android allow two views both have focus ? eeffoc No, two (or more) views cannot have focus at the

Setting cursor to the right on an EditText with HINT Gravity to center

萝らか妹 提交于 2019-12-01 22:34:08
问题 Is this possible? Any EditText attribute to do so? Thanks. 回答1: You can use android:ellipsize="end" android:gravity="center" in your xml when you declare the EditText The first line is to move cursor to the right and the second one to move the hint to the center. An example: <EditText android:id="@+id/txt1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:ellipsize="end" android:gravity="center" android:hint="@string/your_hint_id" /> 回答2: This should be the

Null Pointer Exception - Getting EditText Value

一曲冷凌霜 提交于 2019-12-01 22:22:53
This is my first question on here I will apologize in advance if I didn't ask this question very well. I have looked at my other questions similar to my problem, but I have not found a good solution to satisfy what is going on in my program. So my problem is I am trying to assign a value to a variable called, num1 from my EditText field called, num1TextField , but I am not having any luck so far. The segment inside my java file that throws the exception is: EditText num1Field = (EditText)v.findViewById(R.id.num1TextField); num1 = num1Field.getText().toString(); I appreciate every contribution

Cannot click on EditText after adding it to WindowManager

蹲街弑〆低调 提交于 2019-12-01 22:18:23
问题 I am creating a layout pretty much dynamically. What I am doing is, creating an EditText, adding it to a RelativeLayout object and putting it to UI through WindowManager. How do I get the edittext to be able to type after I do this? Here is a jist of my code RelativeLayout layout = new RelativeLayout(this); private EditText response = new EditText(this); **Set width/height/extra** layout.addView(response, params); //Params are set properly WindowManager myWindow = (WindowManager)

Android EditText cursor “ghosts”

孤街浪徒 提交于 2019-12-01 22:03:34
问题 I am only an occasional Android programmer and can't seem to find an answer to this one. I am guessing I set something up wrong. My app works fine in the emulator, but when I move to a device, the t|e|x|t|l|o|o|k|s|l|i|k|e|t|h|i|s| when I type. My code is as follows, its pretty simple at this point... EditText in xml <EditText android:id="@+id/server_username" android:layout_width="match_parent" android:layout_height="wrap_content" android:ems="10" android:inputType="text" /> MainActivity

How to create a empty bullet paragraph by BulletSpan?

放肆的年华 提交于 2019-12-01 21:45:18
I wanted to create a empty bullet paragraph, but it didn't work. This is my code: EditText contentET = (EditText) findViewById(R.id.content); contentET.setText("abc\n123\n"); Spannable s = contentET.getText(); s.setSpan(new BulletSpan(), 0, 1, Spannable.SPAN_INCLUSIVE_INCLUSIVE); s.setSpan(new BulletSpan(), 4, 5, Spannable.SPAN_INCLUSIVE_INCLUSIVE); s.setSpan(new BulletSpan(), 7, 8, Spannable.SPAN_INCLUSIVE_INCLUSIVE); contentET.setText(s); When i ran above code, it seemed this line doesn't work s.setSpan(new BulletSpan(), 7, 8, Spannable.SPAN_INCLUSIVE_INCLUSIVE); Instead, i saw an unexpected

Android : My app crashes when there is a blank editText field

不羁的心 提交于 2019-12-01 21:31:44
问题 I have a problem with my code. It keeps on crashing when i have a blank editText field. This bit of code is in the settings of my app and works the data fine but when there is a blank field it crashes the program. Here's the code for it. Please don't be harsh because it is my 1st android app. So if anyone knows how to solves the blank edit text field problem that would be greatly appreciated! (Any other comments on how to improve the app would be a help to). Cheers package com.cleanyet

Unwilling EditText onTouchListener Function Call [duplicate]

眉间皱痕 提交于 2019-12-01 21:08:43
Possible Duplicate: public boolean onKey() called twice? I have an EditText field which calls a popUp view with radio buttons. PopUp and RadioGroup implementation works nice. But I just realize when pressed or Touch to EditText, onTouchListener is called 2 times. I also just realize that the reason of my previous question is the same issue. Here is the the EditText; etOdemeSekli = (EditText)findViewById(R.id.etOdemeSekli); etOdemeSekli.setOnTouchListener(new OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { // TODO Auto-generated method stub inflatePopUpOdemeSekli(); Log