我可能会错过一些东西,但我真的不明白:
public class coffee_list extends ListFragment {
private ArrayList<coffee> coffeeList;
private coffee_adapter coffeeAdapter;
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
coffeeList = new ArrayList<coffee>();
coffeeList.add(new coffee("Qaldi Black(Americano)",75.00,0,R.drawable.testicon));
coffeeAdapter = new coffee_adapter(getActivity(), coffeeList);
setListAdapter(coffeeAdapter);
getListView().setDivider(ContextCompat.getDrawable(getActivity(), android.R.color.darker_gray));
getListView().setDividerHeight(1);
}
}
显示:
if(trim($_GET[$slug]) == trim($cat->$slug)) {
$selected = 'selected';
}
else {
$selected = '';
}
var_dump(trim($_GET[$slug]));
var_dump(trim($cat->slug));
var_dump($selected);
答案 0 :(得分:2)
应该在if语句中使用$cat->slug
而不是$cat->$slug