In my custom view when I click on the edittext at first the correct keyboard is displayed (with only numbers) but after a few seconds the the keyboard is switched to standard keyboard and edittext looses focus.
Why is this happening.
Here is the code of the my custo view:
public class SetValueView extends RelativeLayout
{
private ImageView minusButton;
private ImageView plusButton;
private EditText valueField;
public SetValueView(Context context)
{
super(context);
init(context);
}
public SetValueView(Context context, AttributeSet attrs)
{
super(context, attrs);
init(context);
}
public SetValueView(Context context, AttributeSet attrs, int defStyle)
{
super(context, attrs, defStyle);
init(context);
}
private void init(Context context)
{
LayoutInflater layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View rootView = layoutInflater.inflate(R.layout.vg_set_value, this);
this.minusButton = (ImageView) rootView.findViewById(R.id.icon_minus);
this.plusButton = (ImageView) rootView.findViewById(R.id.icon_plus);
this.valueField = (EditText) rootView.findViewById(R.id.field_value);
}
}
And here is the vg_set_layout.xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://ift.tt/nIICcg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/view_set_value_background" >
<ImageView
android:id="@+id/icon_minus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/field_value"
android:layout_alignTop="@+id/field_value"
android:background="@drawable/button_background"
android:clickable="true"
android:src="@drawable/ic_minus" />
<EditText
android:id="@+id/field_value"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/icon_minus"
android:background="@drawable/view_set_value_value_background"
android:gravity="right"
android:inputType="numberDecimal"
android:minWidth="50dp"
android:padding="2dp"
android:textSize="15sp" />
<ImageView
android:id="@+id/icon_plus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@id/field_value"
android:layout_alignTop="@id/field_value"
android:layout_toRightOf="@id/field_value"
android:background="@drawable/button_background"
android:clickable="true"
android:scaleType="centerInside"
android:src="@drawable/ic_plus" />
</RelativeLayout>
 
No comments:
Post a Comment