Beispiel #1
0
  /**
   * 响应事件,处理listView的item的点击事件
   *
   * @param v
   */
  @Override
  public void onClick(View v) {
    Object tag = v.getTag();
    if (tag != null && tag instanceof String) {
      String s = (String) tag;
      String[] split = s.split(":");
      Intent intent;
      // TODO 跳转用户界面Activity
      int location = Integer.parseInt(split[1]);
      if (split[0].equals("GenPhoto")) {
        Toast.makeText(
                getContext(), "点击了" + list.get(location).getGenNickName(), Toast.LENGTH_SHORT)
            .show();
      } else if (split[0].equals("HabitName")) { // TODO 跳转习惯介绍界面Activity
        intent = new Intent(getContext(), HabbitInfoActivity.class);
        intent.putExtra("DetailId", list.get(location).getDetailId());
        startActivity(intent);
      } else if (split[0].equals("PraiseImages")) { // TODO 跳转赞我的人界面Activity
        Toast.makeText(
                getContext(),
                "点击了" + list.get(location).getGenNickName() + "点赞人图标",
                Toast.LENGTH_SHORT)
            .show();
      } else if (split[0].equals("CommentCount")) { // TODO 跳转评论界面Activity或者登录界面
        if (!MyApplication.ISLOADING()) {
          intent = new Intent(getContext(), EntryActivity.class);
          startActivity(intent);
        } else {

        }
      } else if (split[0].equals("PraiseCount")) { // TODO 跳转赞界面Activity或者登录界面
        if (!MyApplication.ISLOADING()) {
          intent = new Intent(getContext(), EntryActivity.class);
          startActivity(intent);
        } else {

        }
      } else if (split[0].equals("CommentListEntity")) { // TODO 跳转评论详情界面Activity或者登录界面
        if (!MyApplication.ISLOADING()) {
          intent = new Intent(getContext(), EntryActivity.class);
          startActivity(intent);
        } else {

        }

      } else { // TODO 跳转详情界面Activity
        intent = new Intent(getContext(), TrendsInfoAcitivity.class);
        intent.putExtra("data", list.get(location));
        startActivity(intent);
      }
    }
  }
Beispiel #2
0
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    bg_layout = inflater.inflate(R.layout.fragment_square_item, container, false);

    // pullToRefreshListView 的初始化及设置
    pullToRefreshListView =
        (PullToRefreshListView) bg_layout.findViewById(R.id.fragment_hot_square_pulltorefreshview);
    list = new LinkedList<>();
    adapter = new TrendsAdapter(list, getContext(), this);
    // 下拉刷新控件处理
    pullToRefreshListView.setAdapter(adapter);
    pullToRefreshListView.setMode(PullToRefreshBase.Mode.PULL_FROM_END);
    pullToRefreshListView.setOnRefreshListener(this);

    UserID = MyApplication.getUSERID();

    // 异步任务请求获取UI数据
    new TrendsTask(this).execute(Configs.NEWTRENDS, lastId, UserID);
    return bg_layout;
  }