【发布时间】:2020-04-17 11:50:00
【问题描述】:
我的想法是从信标中获取标题,然后根据该标题向我发送适当的布局。但突然它不会识别我的询问。像 String == String 一样不行。
这是一个视图的代码,如果你们需要其他东西我会发布或者我们可以创建一个 Skype 会话来教我这个。
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ProximityContent content = nearbyContent.get(position);
String beacon = content.getTitle();
if (beacon == "one") {
if (convertView == null) {
LayoutInflater inflater =
(LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
assert inflater != null;
convertView = inflater.inflate(R.layout.tester_beacon_i, parent, false);
}
} else if (beacon == "two") {
if (convertView == null) {
LayoutInflater inflater =
(LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
assert inflater != null;
convertView = inflater.inflate(R.layout.tester_beacon_ii, parent, false);
}
} else if (beacon == "three") {
if (convertView == null) {
LayoutInflater inflater =
(LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
assert inflater != null;
convertView = inflater.inflate(R.layout.tester_beacon_iii, parent, false);
}
} else {
if (convertView == null) {
LayoutInflater inflater =
(LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
assert inflater != null;
convertView = inflater.inflate(R.layout.tester_beacon_iv, parent, false);
}
}
return convertView;
}
所以每次我的应用启动时,我只获得了 4 次 tester_beacon_iv 布局,而不是同时获得所有 4 个信标上的所有 4 个布局。
附:我正在使用 Estimote 信标。
【问题讨论】:
标签: java android arrays android-studio estimote