Answer the question
In order to leave comments, you need to log in
Why is if not defined?
Passed fragment value
@Override public void onItemClick(View view, int position) {
// do whatever
usr = adapter.getItem(position);
Context context=view.getContext();
Intent intent = new Intent(context, DetailActivity.class);
//intent.putExtra(ItemDetailFragment.ARG_ITEM_ID, (Parcelable) usr);
intent.putExtra("fragment", "OneFragment");
context.startActivity(intent);
}
String fragment= getIntent().getStringExtra("fragment");
if(fragment== "OneFragment")
{
Toast toast2 = Toast.makeText(this, "hello ddd", Toast.LENGTH_SHORT);
toast2.show();
}
Answer the question
In order to leave comments, you need to log in
For reference types, == tests for reference equality, not value equality. Use the .equals() method :if(fragment.equals("OneFragment")) {}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question