通过单击将主活动中的Parse查询适配器中的项目保存到收藏夹适配器

时间:2015-05-12 20:48:38

标签: android onitemclicklistener

我希望能够触摸主要活动中的项目,一旦触摸该项目将保存到收藏夹类。我假设我需要实现和OnItemClickListener,但我无法正确实现它。请帮忙 我还需要添加另一个意图代码并将onclicklistener放在那里吗?如果需要更多信息请告诉我,我现在已经坚持这个问题一段时间了。谢谢

这是我的主要活动代码

import com.parse.ParseQueryAdapter;



public class WingmanListActivity extends ListActivity {

    private ParseQueryAdapter<Tip> mainAdapter;

    private FavoriteTipAdapter favoritesAdapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {


        super.onCreate(savedInstanceState);
        getListView().setClickable(true);

        mainAdapter = new ParseQueryAdapter<Tip>(this, Tip.class);
        mainAdapter.setTextKey("title");
        mainAdapter.setImageKey("photo");

        //Subclass ParseQueryAdapter
        favoritesAdapter = new FavoriteTipAdapter(this);


        //Default view is all wingman tips
        setListAdapter(mainAdapter);

       /* String url = "http://twitter.com/";
        WebView view = (WebView) this.findViewById(R.id.webView);
        view.getSettings().setJavaScriptEnabled(true);
        view.loadUrl(url); */
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_wingman_list, menu);

        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {

            case R.id.action_refresh: {
                updateTipList();
                break;
            }

            case R.id.action_favorites: {
                showFavorites();
                break;
            }

            case R.id.action_new: {
                newTip();
                break;
            }
            case R.id.twitter: {
                twitter();
                break;
                }
            }



        return super.onOptionsItemSelected(item);
    }

    private void twitter() {
        Intent a = new Intent(this, Twitter.class);
        startActivityForResult(a, 0);

    }


    private void updateTipList() {
        mainAdapter.loadObjects();
        setListAdapter(mainAdapter);
    }

    private void showFavorites() {
        favoritesAdapter.loadObjects();
        setListAdapter(favoritesAdapter);

    }

    private void newTip() {
        Intent i = new Intent(this, NewTipActivity.class);
        startActivityForResult(i, 0);

0 个答案:

没有答案