コード例 #1
0
ファイル: InformationActivity.java プロジェクト: wanily/pre
        public void handleMessage(android.os.Message msg) {

          if (msg.what == 0) { // dismiss
            if (mDialog != null && !InformationActivity.this.isFinishing()) {
              mDialog.dismiss();
            }
            mString = new String[popList.size()];
            popList.toArray(mString);
            myAdapter = new MyAdatper();
            searchListView.setAdapter(myAdapter);
            searchListView.setOnItemClickListener(InformationActivity.this);

            mListView.setPinnedHeaderView(
                LayoutInflater.from(InformationActivity.this)
                    .inflate(R.layout.knowledge_information_header, mListView, false));
            mAdapter = new MAdapter();
            mListView.setAdapter(mAdapter);
            mAdapter.setSelectedPosition(todaySelected);
            mAdapter.notifyDataSetInvalidated();
            mListView.setSelection(todaySelected);
          }
        };
コード例 #2
0
ファイル: InformationActivity.java プロジェクト: wanily/pre
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.knowledge_information_activity);

    // 注册广播监听
    IntentFilter filter = new IntentFilter();
    filter.addAction("DataUpdate");
    LocalBroadcastManager.getInstance(this).registerReceiver(broadcastReceiver, filter);

    mImgIcon = (ImageView) findViewById(R.id.img_icon);
    mImgIcon.setOnClickListener(this);
    mImageOut = (ImageView) findViewById(R.id.iv_item_bg_out);
    mImageIn = (ImageView) findViewById(R.id.iv_item_bg_in);

    mListView = (PinnedHeaderListView) findViewById(R.id.information_activity_list);

    mApplication = (PregnancyApplication) getApplication();
    mDbAdapter = mApplication.getCalendarDbAdapter();
    mController = new CalendarDbController(mDbAdapter);

    mImageCacheLoaderForBitmap = new ImageCacheLoaderForBitmap();

    mListView.setOnItemClickListener(this);
    findViewById(R.id.btn_left).setOnClickListener(this);
    findViewById(R.id.btn_right_left).setOnClickListener(this);
    findViewById(R.id.txt_center).setOnClickListener(this);
    // 妈妈怀孕天数
    hasDaysNum =
        BabytreeUtil.getBetweenDays(
            Calendar.getInstance(Locale.CHINA).getTimeInMillis(),
            SharedPreferencesUtil.getLongValue(this, ShareKeys.BIRTHDAY_TIMESTAMP));
    // 首次进去计算今天位置
    todaySelected = 280 - hasDaysNum - 3 * 7 + 1;

    View view = View.inflate(this, R.layout.knowledge_information_search_menu, null);
    searchListView = (ListView) view.findViewById(R.id.layout_list_view);

    DisplayMetrics metrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(metrics);
    int height = 0;
    if (metrics.heightPixels == 480) {
      height = (metrics.heightPixels) * 1 / 2 + 12;
    } else if (metrics.heightPixels == 854) {
      height = (metrics.heightPixels) * 1 / 2 - 35;
    } else {
      height = (metrics.heightPixels) * 1 / 2 - 5;
    }
    int width = (metrics.widthPixels) * 1 / 2 - 65;
    mMenu = new PopupWindow(view, width, height);
    mMenu.setBackgroundDrawable(getResources().getDrawable(R.drawable.sort_bkg_new));
    mMenu.setOutsideTouchable(true);
    mMenu.update();
    mMenu.setTouchable(true);
    mMenu.setFocusable(true);

    initData();

    // 判断是否为爸爸版,更改UI样式
    if (mIsFather) {
      findViewById(R.id.layout_title)
          .setBackgroundDrawable(getResources().getDrawable(R.drawable.title_back));
      findViewById(R.id.btn_left)
          .setBackgroundDrawable(getResources().getDrawable(R.drawable.f_btn_back));
      findViewById(R.id.btn_right_left).setVisibility(View.GONE);
    }
  }