我想知道如果[sex_b,gender_c] setError为RadioGroup[性别],RadioButton如果它为空.
这就是我获得RadioButton价值的方式:
private boolean genradiocheck() {
boolean gender_flag = false;
if (gender.getCheckedRadioButtonId() == -1) {
} else {
gender_b = (RadioButton) findViewById(gender
.getCheckedRadioButtonId());
System.out.println("*********************" + gender_b.getText());
gender_flag = true;
}
return gender_flag;
}
Run Code Online (Sandbox Code Playgroud)
现在我的问题是,如何将其放入字符串并检查空值?
这是用于注册表单验证.谢谢.
我正在尝试将JSON数组提取到一个AutoCompleteTextView但是我在下拉列表中获取每个值两次.
JSON:
{"names":[{"id":"1","names":"jacob"},{"id":"2","names":"amy"},{"id":"3","names":"melissa"}],"success":1,"message":"Successfully found "}
Run Code Online (Sandbox Code Playgroud)
类Ajax:
class Ajax5 extends AsyncTask<String, String, String> {// JSON STARTS HERE
// new CreateNewProduct().execute();
protected ArrayList<NameValuePair> parameters;
JSONObject json;
public Ajax5() {
super();
parameters = new ArrayList<NameValuePair>();
}
@Override
protected void onPreExecute() {
super.onPreExecute();
}
protected String doInBackground(String... args) {
JSONParser jParser = new JSONParser();
json = jParser
.makeHttpRequest(
"http:link.php",
"GET", this.parameters);
try {
Log.d("Create Response", "four"
+ json.getJSONObject("1").toString());
} catch (JSONException e) {
e.printStackTrace();
}
return null;
}
protected void …Run Code Online (Sandbox Code Playgroud) DatePicker我的应用程序中有一个以这种方式设置:
布局:
<TextView
android:id="@+id/traveltext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1.11"
android:text="Date Of Travel"
android:textStyle="bold" />
<EditText
android:id="@+id/txtDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" >
</EditText>
<Button
android:id="@+id/btnCalendar"
android:layout_width="30dp"
android:layout_height="42dp"
android:layout_marginRight="50dp"
android:background="@drawable/date" >
</Button>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
全球价值观:
Button btnCalendar;
EditText txtDate;
private int mYear, mMonth, mDay;
Run Code Online (Sandbox Code Playgroud)
OnCreate:
btnCalendar = (Button) findViewById(R.id.btnCalendar);
txtDate = (EditText) findViewById(R.id.txtDate);
btnCalendar.setOnClickListener(this);
Run Code Online (Sandbox Code Playgroud)
方法 :
@Override
public void onClick(View v) {
if (v == btnCalendar) {
// Process to get Current Date
final Calendar c = Calendar.getInstance();
mYear = c.get(Calendar.YEAR);
mMonth = c.get(Calendar.MONTH);
mDay …Run Code Online (Sandbox Code Playgroud)