ここに私はserver.ifから来ている1リストビューを表示しています私はいくつかの警告ボックスを開きたいです...しかし、私は条件を満たす必要がありますeg.if listitem文字列 "Biancaピザ" alertbox else toast "こんにちは" ..ここで私のコードでは、リストビュー項目の文字列を取っていません。アンドロイドの「if else」条件での文字列値の照合方法は?
トースト(私が前に置いた条件であれば、正しいかどうかをチェックするコード)のリストビュー項目の第1の値ですが、私はそれが機能していないことを比較しています。
「ビアンカピザ」を食べるのが好きですが、「ビアンカピザ」と比較したいときは、一致する必要があります。
public class ListViewAdapter extends BaseAdapter {
// Declare Variables
Context context;
LayoutInflater inflater;
ArrayList<HashMap<String, String>> data;
ImageLoader imageLoader;
HashMap<String, String> resultp = new HashMap<String, String>();
public ListViewAdapter(Context context,
ArrayList<HashMap<String, String>> arraylist) {
this.context = context;
data = arraylist;
imageLoader = new ImageLoader(context);
}
@Override
public int getCount() {
return data.size();
}
@Override
public Object getItem(int position) {
return null;
}
@Override
public long getItemId(int position) {
return 0;
}
public View getView(final int position, View convertView, ViewGroup parent) {
// Declare Variables
TextView id;
TextView name;
TextView population;
CircleImageView image;
inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View itemView = inflater.inflate(R.layout.list_item1, parent, false);
// Get the position
resultp = data.get(position);
// Locate the TextViews in listview_item.xml
// id = (TextView) itemView.findViewById(R.id.idq);
name = (TextView) itemView.findViewById(R.id.type1);
// Locate the ImageView in listview_item.xml
image = (CircleImageView) itemView.findViewById(R.id.subimg);
// icon = (ImageView) itemView.findViewById(R.id.arrow);
// Capture position and set results to the TextViews
// id.setText(resultp.get(SubMenu.RANK));
name.setText(resultp.get(SubMenu.COUNTRY));
// Capture position and set results to the ImageView
// Passes flag images URL into ImageLoader.class
imageLoader.DisplayImage(resultp.get(SubMenu.FLAG), image);
// imageLoader.DisplayImage(resultp.get(SubMenu.FLAG), icon);
// Capture ListView item click
/**itemView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// Get the position
resultp = data.get(position);
Intent intent = new Intent(context, SingleItemView.class);
// Pass all data rank
intent.putExtra("rank", resultp.get(MainActivity.RANK));
// Pass all data country
intent.putExtra("country", resultp.get(MainActivity.COUNTRY));
// Pass all data population
intent.putExtra("population",resultp.get(MainActivity.POPULATION));
// Pass all data flag
intent.putExtra("flag", resultp.get(MainActivity.FLAG));
// Start SingleItemView Class
context.startActivity(intent);
}
});*/
return itemView;
}
}
あなたが意味 – Pavya
文字列内のスイッチでhttps://docs.oracle.com/javase/8/docs/technotes/guides/language/strings-switch.htmlを行い、それは大文字と小文字を区別すべきですか? –
equalsIgnoreCaseの代わりにequalsを試してみてください..... –