This is a question that I have searched for on this page, but the solutions that I have been finding, I have implemented them, but they have not worked for me, and they will appear commented on in the code, to see if something escapes me or any nonsense but I do not get it out.
What I want to do is: I have a ListView
, and when I click on an element show me "You have selected XXXXX element" , and now comes what I want to implement, the method onClick , then, always the application stops and there is no way.
Important: I work with Fragments
, my ListView
is in Fragment
and I want it to take me to another Fragment
.
public class UsersAdapter extends BaseAdapter {
private static LayoutInflater inflater = null;
private List<User> allUsers;
private Context context;
/*************
* Constructor
*****************/
public UsersAdapter(Context ctx, ArrayList<User> data) {
context = ctx;
allUsers = data;
inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
@Override
public int getCount() {
return allUsers.size();
}
@Override
public Object getItem(int position) {
return position;
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
View rowView = convertView;
UserViewHolder holder = new UserViewHolder();
final User user = allUsers.get(position);
if(convertView==null)
{
rowView = inflater.inflate(R.layout.boxer_item, null);
holder.name = (TextView) rowView.findViewById(R.id.txt_name);
holder.icon = (ImageView) rowView.findViewById(R.id.img_user);
rowView.setTag(holder);
}
else
{
holder = (UserViewHolder) rowView.getTag();
}
holder.name.setText(user.getName());
Glide.with(context).load(user.getImage()).into(holder.icon);
rowView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Toast.makeText(context, "You Clicked " + user.getName(), Toast.LENGTH_SHORT).show();
// Lo que hago en este "if" es comparar lo que pulso con el nombre del elemento, para evitar una búsqueda más compleja.
if (user.getName() == "Ramon \nDekkers"){
Toast.makeText(context, "You ClickedFFFFFFFFFFFFEFEFF " + user.getName(), Toast.LENGTH_LONG).show();
////////////// ESTO ES LO QUE INTENTÉ YO /////////////////
// Intent ramon = new Intent (context,Ramon_dekkers.class);
// ramon.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
// context.startActivity(ramon);
//v.getContext().startActivity(context.getApplicationContext(),Ramon_dekkers.class);
// v.getContext().startActivity(new Intent(context,Ramon_dekkers.class));
''////////////// ESTO ES LO QUE INTENTÉ YO /////////////////''
}
}
});
return rowView;
}
private static class UserViewHolder {
public ImageView icon;
public TextView name;
}
}
The error that shows me is the following:
FATAL EXCEPTION: main android.content.ActivityNotFoundException: Unable to find explicit activity class and then if declared in the manifest.xml