AndroidAPS/app/src/main/java/info/nightscout/androidaps/startupwizard/SWUrl.java

50 lines
1.3 KiB
Java
Raw Normal View History

2018-04-20 17:27:31 +02:00
package info.nightscout.androidaps.startupwizard;
2018-04-25 14:29:20 +02:00
import android.content.Context;
import android.text.InputType;
import android.view.View;
import android.widget.EditText;
import android.widget.LinearLayout;
2018-04-27 12:30:45 +02:00
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
2018-04-25 14:29:20 +02:00
import java.util.List;
2018-04-20 17:27:31 +02:00
public class SWUrl extends SWItem {
2018-04-27 12:30:45 +02:00
private static Logger log = LoggerFactory.getLogger(SWUrl.class);
2018-04-25 14:29:20 +02:00
private List<String> labels;
private List<String> values;
private String groupName;
2018-04-20 17:27:31 +02:00
public SWUrl() {
super(Type.URL);
}
2018-04-25 14:29:20 +02:00
2018-04-27 16:04:08 +02:00
public void setName(String name){
this.groupName = name;
}
2018-04-25 14:29:20 +02:00
public void setOptions(List<String> labels, List<String> values){
this.labels = labels;
this.values = values;
}
@Override
2018-04-27 12:30:45 +02:00
public void generateDialog(View view, LinearLayout layout) {
2018-04-25 14:29:20 +02:00
Context context = view.getContext();
2018-04-27 12:30:45 +02:00
if(values.get(values.size()-1) != "" && values.get(values.size()-1) != null) {
EditText editText = new EditText(context);
editText.setId(View.generateViewId());
2018-04-27 12:30:45 +02:00
// get the last value in list
editText.setText(values.get(values.size()-1));
editText.setInputType(InputType.TYPE_CLASS_TEXT);
editText.setMaxLines(1);
layout.addView(editText);
2018-04-25 14:29:20 +02:00
}
}
2018-04-20 17:27:31 +02:00
}