Example #1
0
  @Override
  public void onClick(View v) {
    FragmentActivity activity = getActivity();
    if (activity instanceof MenuListener) {
      String menuText = null;

      if (v instanceof TextView) {
        CharSequence text = ((TextView) v).getText();
        if (text != null) {
          menuText = text.toString();
        }
      }

      ((MenuListener) activity).onMenuClicked(v.getId(), menuText, mSelectedMenuId != v.getId());
      mSelectedMenuId = v.getId();
    }
  }
Example #2
0
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    View v = convertView;
    Object item = getItem(position);
    if (item instanceof User) {
      // if (v == null) {
      // v = LayoutInflater.from(mContext).inflate(
      // R.layout.v2_menu_row_item, parent, false);
      // }//android 2.x 版本会报空针
      v = LayoutInflater.from(mContext).inflate(R.layout.v2_menu_row_user, parent, false);
      TextView tv_name = (TextView) v.findViewById(R.id.tv_user_name);
      TextView tv_id = (TextView) v.findViewById(R.id.tv_user_id);
      tv_name.setText(((User) item).mName);
      tv_id.setText(((User) item).mId);
    } else {
      v = LayoutInflater.from(mContext).inflate(R.layout.v2_menu_row_item, parent, false);
      //			if (v == null) {
      //				v = LayoutInflater.from(mContext).inflate(
      //						R.layout.v2_menu_row_item, parent, false);
      //			}
      ImageView iv_image = (ImageView) v.findViewById(R.id.iv_menu_item_image);
      iv_image.setImageResource(((Item) item).mIconRes);
      TextView tv_text = (TextView) v.findViewById(R.id.tv_menu_item_text);
      tv_text.setText(((Item) item).mTitle);
      if (((Item) item).selected) {
        tv_text.setTextColor(mContext.getResources().getColor(R.color.v2_blue));
      } else {
        tv_text.setTextColor(mContext.getResources().getColor(R.color.v2_button));
      }
      TextView tv_text_alert = (TextView) v.findViewById(R.id.tv_menu_item_image_alert);
      if (((Item) item).mNum > 0) {
        tv_text_alert.setText(((Item) item).mNum > 99 ? "99+" : "" + ((Item) item).mNum);
        tv_text_alert.setVisibility(View.VISIBLE);
      } else {
        tv_text_alert.setVisibility(View.GONE);
      }
    }
    if (position == mActivePosition) {
      mListener.onActiveViewChanged(v);
    }

    return v;
  }
Example #3
0
  public LogIn(JPanel Start) {
    this.setName("Log In");
    setSize(700, 450);
    setLayout(null);

    parent = Start;

    lblStatusServer = new JLabel();
    lblStatusServer.setHorizontalAlignment(SwingConstants.CENTER);
    lblStatusServer.setFont(new Font("Times New Roman", Font.BOLD, 30));
    lblStatusServer.setBounds(10, 361, 639, 40);
    add(lblStatusServer);

    JLabel lblName = new JLabel();
    lblName.setText("Name/Mail: ");
    lblName.setHorizontalAlignment(SwingConstants.LEFT);
    lblName.setFont(new Font("Times New Roman", Font.BOLD, 12));
    lblName.setBounds(10, 11, 130, 40);
    add(lblName);

    JLabel lblPassword = new JLabel();
    lblPassword.setText("Passwort: ");
    lblPassword.setHorizontalAlignment(SwingConstants.LEFT);
    lblPassword.setFont(new Font("Times New Roman", Font.BOLD, 12));
    lblPassword.setBounds(10, 51, 130, 40);
    add(lblPassword);

    JLabel lblCode = new JLabel();
    lblCode.setText("Sicherheitscode: ");
    lblCode.setHorizontalAlignment(SwingConstants.LEFT);
    lblCode.setFont(new Font("Times New Roman", Font.BOLD, 12));
    lblCode.setBounds(10, 131, 130, 40);
    add(lblCode);

    JTextField txtName = new JTextField();
    txtName.setBounds(162, 11, 200, 20);
    add(txtName);

    JTextField txtPasswort = new JPasswordField();
    txtPasswort.setBounds(162, 51, 200, 20);
    add(txtPasswort);

    JTextField txtCode = new JTextField();
    txtCode.setBounds(162, 131, 200, 20);
    add(txtCode);

    JButton btnEinloggen = new MenuButton(3);
    btnEinloggen.setText("Einloggen");
    btnEinloggen.setBounds(10, 216, 89, 23);
    btnEinloggen.addActionListener(MenuListener.getInstance());
    add(btnEinloggen);
    btnEinloggen.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            String name = txtName.getText();
            String passwort = txtPasswort.getText();
            // sendet die Eingegebenden Daten
            Client.getInstance().send("FLAG_LOGIN;" + name + ',' + passwort);
          }
        });

    JButton btnZurck = new MenuButton(0);
    btnZurck.setText("Back");
    btnZurck.setBounds(417, 216, 89, 23);
    btnZurck.addActionListener(MenuListener.getInstance());
    add(btnZurck);
    btnZurck.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            Frame.getInstance().switchPanel(Frame.START);
          }
        });
  }