我只是偶尔的Android程序员,似乎无法找到答案。我猜我设置错了。我的应用程序在模拟器中工作正常,但当我移动到设备时,
T | E | X | T |升| O | O | K | S |升| I | K | E | T | H | I | S |
我输入的时候。我的代码如下,此时非常简单......
xml中的EditText
<EditText
android:id="@+id/server_username"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="text" />
MainActivity.java
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final Button clickButton = (Button) findViewById(R.id.save_button);
final EditText serverUrl = (EditText)findViewById(R.id.server_url);
final EditText serverUsername = (EditText)findViewById(R.id.server_username);
final EditText serverPassword = (EditText)findViewById(R.id.server_password);
clickButton.setOnClickListener( new OnClickListener() {
@Override
public void onClick(View arg0) {
String url = serverUrl.getText().toString();
String username = serverUsername.getText().toString();
String password = serverPassword.getText().toString();
ContentValues values = new ContentValues();
values.put(CredentialsProvider.SERVERURL, url);
values.put(CredentialsProvider.USERNAME, username);
values.put(CredentialsProvider.PASSWORD, password);
getContentResolver().update(
CredentialsProvider.CONTENT_URI, values, null, null);
}
});
String URL = "content://com.dont.touch.jobus.rum/credentials/1";
Uri creds = Uri.parse(URL);
Cursor c =getContentResolver().query(creds, null, null, null, "username");
if (c.moveToPosition(0)) {
serverUrl.setText(c.getString(c.getColumnIndex( CredentialsProvider.SERVERURL)));
serverUsername.setText(c.getString(c.getColumnIndex( CredentialsProvider.USERNAME)));
serverPassword.setText(c.getString(c.getColumnIndex( CredentialsProvider.PASSWORD)));
} else {
ContentValues values = new ContentValues();
values.put(CredentialsProvider.SERVERURL,
"not configured");
values.put(CredentialsProvider.USERNAME,
"not configured");
values.put(CredentialsProvider.PASSWORD,
"not configured");
getContentResolver().insert(
CredentialsProvider.CONTENT_URI, values);
}
}
@Override
protected void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
}
}