Commit 6e742ed5 by 石璀亮

feat(model):add the product model choose ui, and logic for choose

1 parent 581aa6a7
package com.nbbsw.cuiliang.systemsetting;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
/**
* Created by st on 17-7-19.
* Function: The Product Model Setting.
*/
public class ProductModelActivity extends AppCompatActivity {
public static int mSelectedType;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_model);
// Choose the model for the product
Button chooseButton = (Button) findViewById(R.id.choose_type);
chooseButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
chooseTypeOfProduct();
}
});
// Clean the model input text.
Button cleanButton = (Button) findViewById(R.id.model_clean);
cleanButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
EditText modelType = (EditText)findViewById(R.id.model_type);
modelType.setText("");
}
});
// Reset product model to default.
Button resetButton = (Button) findViewById(R.id.model_reset);
resetButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String value = SystemSetting.handleModelStatus();
EditText modelType = (EditText)findViewById(R.id.model_type);
modelType.setText(value);
}
});
// Confirm product model
Button confirmButton = (Button) findViewById(R.id.model_confirm);
confirmButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
EditText modelType = (EditText)findViewById(R.id.model_type);
String value = SystemSetting.handleModelStatus(modelType.getText().toString());
modelType.setText(value);
}
});
}
/**
* Choose type of product.
* A Recommend for user input.
*/
public void chooseTypeOfProduct(){
final String[] arrayFruit = new String[] { "4G", "3G", "2G", "1G" };
Dialog alertDialog = new AlertDialog.Builder(this).
setTitle("选择型号").
setIcon(R.drawable.ic_launcher)
.setSingleChoiceItems(arrayFruit, 0, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
ProductModelActivity.mSelectedType = which;
}
}).
setPositiveButton("确认", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
EditText modelType = (EditText)findViewById(R.id.model_type);
modelType.setText(arrayFruit[ProductModelActivity.mSelectedType]);
}
}).
setNegativeButton("取消", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
}).
create();
alertDialog.show();
}
}
......@@ -49,4 +49,15 @@ public class SystemSetting {
}
}
public static String handleModelStatus() {
String value = "4G";
return handleModelStatus(value);
}
public static String handleModelStatus(String value) {
Log.d("SystemSetting", "Model:" + value);
// TODO: System setting For change the product model. eg. 3G, 4G...
return value;
}
}
\ No newline at end of file
......@@ -10,14 +10,14 @@
android:text="@string/model_input_tips" />
<EditText
android:id="@+id/editText2"
android:id="@+id/model_type"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName" />
<Button
android:id="@+id/button4"
android:id="@+id/choose_type"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="选择其他型号" />
......@@ -26,21 +26,21 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<Button
android:id="@+id/button"
android:id="@+id/model_confirm"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="确定" />
<Button
android:id="@+id/button2"
android:id="@+id/model_reset"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="重置" />
<Button
android:id="@+id/button3"
android:id="@+id/model_clean"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!