Reputation: 1550
I've got my app working, but can't get the keypad to only show numeric keys (including decimals). I'm using phonegap, so I don't know if that's what's causing the issue, but I've tried adding:
<EditText android:numeric="decimal" />
into both my AndroidManifest.xml and the activity_main.xml but no luck.
I'm thinking I need to change something inside phonegap, because my activity_main.xml only shows the hello world string and not the other components of my app.
EDIT
Here's the "activity_main.xml"
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="@string/hello_world"
tools:context=".MainActivity" />
<EditText
android:inputType="number">
</EditText>
</RelativeLayout>
And now here's the AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.yourappname.yourappname"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" />
<supports-screens
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:resizeable="true"
android:anyDensity="true" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<EditText android:inputType="phone" android:numeric="decimal"></EditText>
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale"
android:name=".MainActivity"
android:label="@string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Upvotes: 2
Views: 1751
Reputation: 2147
Hii you haven't given height and width to your editext.so it will not be shown in your layout file.As far as input is concerned,inputType=number will popup Number pad.Use below code for EditText.
<EditText
android:id="@+id/edittext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="number"/>
Upvotes: 1