如果Layer
为"LVS"
或"PRJ"
,我想检查一个组合框。如果选择了其中一个,我想将路径作为String
返回,但该函数始终返回"null"
。有人可以帮助我吗?
private String getGroovyPath(MyTitleAreaDialog dialog)
{
String LayerLVS = "lvs/dev/scripts/123/aderf/de/lock/clt/Simplescript.groovy";
String LayerPRJ = "prj/dev/scripts/123/aderf/de/lock/clt/Simplescript.groovy"";
if(dialog.getLayer() == "LVS")
{
return LayerLVS;
}
else if(dialog.getLayer() == "PRJ")
{
return LayerPRJ;
}
return null;
}
答案 0 :(得分:0)
,您应该使用public class MyAdapter extends ArrayAdapter<ListItem> {
int res = 0;
int textRes = 0;
public MyAdapter(Context context, int resource, int textViewResourceId) {
super(context, resource, textViewResourceId);
res = resource;
textRes = textViewResourceId;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = LayoutInflater.from(parent.getContext()).inflate(res, parent, false);
}
ListItem item = getItem(position);
if (item.hasBackground) {
convertView.setBackgroundColor(Color.BLUE);
} else {
convertView.setBackgroundColor(Color.TRANSPARENT);
}
TextView textView = (TextView) convertView.findViewById(textRes);
textView.setText(item.value);
return convertView;
}
}
或equals()
函数来比较两个字符串。试试下面的代码:
equalsIgnoreCase()