@Override
  public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

    if (!dualScreen) {
      if (null == onItemClickNewActivity) {
        onItemClickNewActivity = new EnterJsonArticle(this);
      }
      onItemClickNewActivity.onItemClick(parent, view, position, id);

    } else {
      String guid = (String) parent.getItemAtPosition(position);
      if (StringUtil.isEmpty(guid)) return;

      guid = guid.trim();

      int pid = StringUtil.getUrlParameter(guid, "pid");
      int tid = StringUtil.getUrlParameter(guid, "tid");
      int authorid = StringUtil.getUrlParameter(guid, "authorid");
      ArticleContainerFragment f = ArticleContainerFragment.create(tid, pid, authorid);
      FragmentManager fm = getSupportFragmentManager();
      FragmentTransaction ft = fm.beginTransaction();

      ft.replace(R.id.item_detail_container, f);
      Fragment f1 = fm.findFragmentById(R.id.item_list);
      f1.setHasOptionsMenu(false);
      f.setHasOptionsMenu(true);
      ft.commit();

      ListView listview = (ListView) parent;
      Object a = parent.getAdapter();
      TopicListAdapter adapter = null;
      if (a instanceof TopicListAdapter) {
        adapter = (TopicListAdapter) a;
      } else if (a instanceof HeaderViewListAdapter) {
        HeaderViewListAdapter ha = (HeaderViewListAdapter) a;
        adapter = (TopicListAdapter) ha.getWrappedAdapter();
        position -= ha.getHeadersCount();
      }
      adapter.setSelected(position);
      listview.setItemChecked(position, true);
    }
  }
コード例 #2
0
  @Override
  public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    String guid = (String) parent.getItemAtPosition(position);
    if (StringUtil.isEmpty(guid)) return;

    guid = guid.trim();

    int pid = StringUtil.getUrlParameter(guid, "pid");
    int tid = StringUtil.getUrlParameter(guid, "tid");
    int authorid = StringUtil.getUrlParameter(guid, "authorid");

    Intent intent = new Intent();
    intent.putExtra("tab", "1");
    intent.putExtra("tid", tid);
    intent.putExtra("pid", pid);
    intent.putExtra("authorid", authorid);
    if (fromreplyactivity) {
      intent.putExtra("fromreplyactivity", 1);
    }
    ListView listview = (ListView) parent;
    Object a = parent.getAdapter();
    TopicListAdapter adapter = null;
    if (a instanceof TopicListAdapter) {
      adapter = (TopicListAdapter) a;
    } else if (a instanceof HeaderViewListAdapter) {
      HeaderViewListAdapter ha = (HeaderViewListAdapter) a;
      adapter = (TopicListAdapter) ha.getWrappedAdapter();
      position -= ha.getHeadersCount();
    }
    adapter.setSelected(position);
    listview.setItemChecked(position, true);

    intent.setClass(activity, PhoneConfiguration.getInstance().articleActivityClass);
    activity.startActivity(intent);
    if (PhoneConfiguration.getInstance().showAnimation)
      activity.overridePendingTransition(R.anim.zoom_enter, R.anim.zoom_exit);
  }