Go to another activity from a list item with parse.com site data

3

I would like to know how I could do to call another activity through an item in the list where the data is used from the parse.com site. For example, I have this code:

public class ListViewAdapterPizzarias extends BaseAdapter {

// Declare Variables

Context context;
LayoutInflater inflater;
ImageLoader imageLoader;
private List<WorldPopulation> worldpopulationlist = null;
private ArrayList<WorldPopulation> arraylist;

public ListViewAdapterPizzarias(Context context,
                                List<WorldPopulation> worldpopulationlist) {
    this.context = context;
    this.worldpopulationlist = worldpopulationlist;
    inflater = LayoutInflater.from(context);
    this.arraylist = new ArrayList<WorldPopulation>();
    this.arraylist.addAll(worldpopulationlist);
    imageLoader = new ImageLoader(context);
}

public class ViewHolder {

    TextView nome;
    TextView telefone;
    TextView endereco;
    TextView status;
}

@Override
public int getCount() {
    return worldpopulationlist.size();
}

@Override
public Object getItem(int position) {
    return worldpopulationlist.get(position);
}

@Override
public long getItemId(int position) {
    return position;
}

public View getView(final int position, View view, ViewGroup parent) {
    final ViewHolder holder;
    if (view == null) {
        holder = new ViewHolder();

        view = inflater.inflate(R.layout.item_lista_pizzarias, null);
        // Locate the TextViews in listview_item.xml
        holder.nome = (TextView) view.findViewById(R.id.nome);
        holder.endereco = (TextView) view.findViewById(R.id.endereco);
        holder.telefone = (TextView) view.findViewById(R.id.telefone);
        holder.status = (TextView) view.findViewById(R.id.status);
        view.setTag(holder);


    } else {
        holder = (ViewHolder) view.getTag();
    }
    // Set the results into TextViews

    holder.nome.setText(worldpopulationlist.get(position).getNome());
    holder.endereco.setText(worldpopulationlist.get(position).getEndereco());
    holder.telefone.setText(worldpopulationlist.get(position).getTelefone());
    holder.status.setText(worldpopulationlist.get(position).getStatus());


    ///teste
    // Listen for ListView Item Click
    view.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // Send single item click data to SingleItemView Class
            Intent intent = new Intent(context, MainActivity.class);

   //O que colocar aqui para buscar o dado do site parse.com e chamar a outra activity?

        }
    });
    return view;
}

}
    
asked by anonymous 27.04.2015 / 04:45

1 answer

0

It is not interesting to realize this logic within your Adapter. From your ListView you have the setOnItemClickListener method which is the best way to perform an action from the click on an item in the list.

To start an Activity you need another Activity to create a Intent and use the 'startActivity ()' method, for example:

Intent i = new Intent(MyActivity.this, MyNewActivity.class);
startActivity(i);

If you are using your ListView in a Fragment, use the getActivity() method to create Intent, for example:

Intent i = new Intent(getActivity(), MyNewActivity.class);
getActivity().startActivity(i);
    
27.04.2015 / 16:42