将路径作为字符串返回

时间:2016-07-20 10:00:28

标签: java string function path return

如果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;
}

1 个答案:

答案 0 :(得分:0)

在java中

,您应该使用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()