@Override
    public View onCreateView(
        LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

      Bundle args = getArguments();
      final int x = args.getInt(ARG_SECTION_NUMBER);

      View rootView;

      if (x == 0) {
        rootView = inflater.inflate(R.layout.fragment_rect_prism_vol, container, false);
        assignImageView(rootView, R.id.rect_img_vol);
      } else {
        rootView = inflater.inflate(R.layout.fragment_rect_prism, container, false);
        assignImageView(rootView, R.id.rect_img, true);
      }

      final EditText wTxt = (EditText) rootView.findViewById(R.id.rect_width);
      final EditText hTxt = (EditText) rootView.findViewById(R.id.rect_height);
      final EditText lTxt = (EditText) rootView.findViewById(R.id.rect_length);
      final TextView vTxt = (TextView) rootView.findViewById(R.id.rect_vol_num);

      TextView vTitle = (TextView) rootView.findViewById(R.id.rect_vol_title);

      wTxt.setOnKeyListener(
          new View.OnKeyListener() {
            @Override
            public boolean onKey(View v, int keyCode, KeyEvent event) {
              calc(wTxt, hTxt, lTxt, vTxt, x);
              return false;
            }
          });

      hTxt.setOnKeyListener(
          new View.OnKeyListener() {
            @Override
            public boolean onKey(View v, int keyCode, KeyEvent event) {
              calc(wTxt, hTxt, lTxt, vTxt, x);
              return false;
            }
          });

      if (x == 0) {
        vTitle.setText("Volume = ");

      } else if (x == 1) {
        vTitle.setText("Surface Area = ");
      }

      return rootView;
    }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    if (DEBUG_LIFECYCLE) logger.debug("onCreateView()");
    View v = inflater.inflate(R.layout.chatview_main, container, false);

    uiLines = (ListView) v.findViewById(R.id.chatview_lines);
    uiInput = (EditText) v.findViewById(R.id.chatview_input);
    uiSend = (ImageButton) v.findViewById(R.id.chatview_send);
    uiTab = (ImageButton) v.findViewById(R.id.chatview_tab);

    uiSend.setOnClickListener(this);
    uiTab.setOnClickListener(this);
    uiInput.setOnKeyListener(this); // listen for hardware keyboard
    uiInput.addTextChangedListener(
        this); // listen for software keyboard through watching input box text
    uiInput.setOnEditorActionListener(
        this); // listen for software keyboard's “send” click. see onEditorAction()

    uiLines.setFocusable(false);
    uiLines.setFocusableInTouchMode(false);

    CopyPaste cp = new CopyPaste(activity, uiInput);
    uiInput.setOnLongClickListener(cp);
    uiLines.setOnItemLongClickListener(cp);

    uiMore = (ViewGroup) inflater.inflate(R.layout.more_button, null);
    uiMoreButton = (Button) uiMore.findViewById(R.id.button_more);
    uiMoreButton.setOnClickListener(this);
    uiLines.addHeaderView(uiMore);
    status = Buffer.LINES.CAN_FETCH_MORE;

    online = true;
    return v;
  }
  @Override
  protected void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.edit_slide_duration);

    int dur;
    if (icicle == null) {
      // Get extra from intent.
      Intent intent = getIntent();
      mCurSlide = intent.getIntExtra(SLIDE_INDEX, 1);
      mTotal = intent.getIntExtra(SLIDE_TOTAL, 1);
      dur = intent.getIntExtra(SLIDE_DUR, 8);
    } else {
      mState = icicle.getBundle(STATE);

      mCurSlide = mState.getInt(SLIDE_INDEX, 1);
      mTotal = mState.getInt(SLIDE_TOTAL, 1);
      dur = mState.getInt(SLIDE_DUR, 8);
    }

    // Label.
    mLabel = (TextView) findViewById(R.id.label);
    mLabel.setText(
        getString(R.string.duration_selector_title) + " " + (mCurSlide + 1) + "/" + mTotal);

    // Input text field.
    mDur = (EditText) findViewById(R.id.text);
    mDur.setText(String.valueOf(dur));
    mDur.setOnKeyListener(mOnKeyListener);

    // Done button.
    mDone = (Button) findViewById(R.id.done);
    mDone.setOnClickListener(mOnDoneClickListener);
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    ViewGroup container = (ViewGroup) findViewById(R.id.Content);
    ViewGroup.inflate(this, R.layout.search, container);

    searchText = (EditText) findViewById(R.id.SearchText);
    searchText.setOnKeyListener(this);
    inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    // only will trigger it if no physical keyboard is open
    if (inputMethodManager != null) {
      inputMethodManager.showSoftInput(searchText, InputMethodManager.SHOW_IMPLICIT);
    }

    ImageButton searchButton = (ImageButton) findViewById(R.id.search_go_button);
    searchButton.setOnClickListener(this);

    endDate = new GregorianCalendar();
    startDate = (Calendar) endDate.clone();
    startDate.add(Calendar.DATE, -7);

    startDateButton = (Button) findViewById(R.id.StartDateButton);
    endDateButton = (Button) findViewById(R.id.EndDateButton);
    startDateButton.setText(dateFormat.format(startDate.getTime()));
    endDateButton.setText(dateFormat.format(endDate.getTime()));
    startDateButton.setOnClickListener(this);
    endDateButton.setOnClickListener(this);
  }
Example #5
0
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // 뷰를 인플레이트 시킨다.
    setContentView(R.layout.main);

    // UI 위젯들에 대한 레퍼런스를 얻어온다.
    ListView myListView = (ListView) findViewById(R.id.myListView);
    final EditText myEditText = (EditText) findViewById(R.id.myEditText);

    // 해야 할 일들을 담기 위한 배열 리스트(array list)를 만든다.
    final ArrayList<String> todoItems = new ArrayList<String>();

    // 이 배열을 리스트 뷰와 묶기 위한 배열 어댑터(array adapter)를 만든다.
    final ArrayAdapter<String> aa;
    aa = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, todoItems);

    // 이 배열 어댑터를 리스트 뷰와 묶는다.
    myListView.setAdapter(aa);

    myEditText.setOnKeyListener(
        new OnKeyListener() {
          public boolean onKey(View v, int keyCode, KeyEvent event) {
            if (event.getAction() == KeyEvent.ACTION_DOWN)
              if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER) {
                todoItems.add(0, myEditText.getText().toString());
                aa.notifyDataSetChanged();
                myEditText.setText("");
                return true;
              }
            return false;
          }
        });
  }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    if (DEBUG_LIFECYCLE) logger.warn("{} onCreateView()", fullName);
    View v = inflater.inflate(R.layout.chatview_main, container, false);

    uiLines = (ListView) v.findViewById(R.id.chatview_lines);
    uiInput = (EditText) v.findViewById(R.id.chatview_input);
    uiSend = (ImageButton) v.findViewById(R.id.chatview_send);
    uiTab = (ImageButton) v.findViewById(R.id.chatview_tab);

    uiSend.setOnClickListener(this);
    uiTab.setOnClickListener(this);
    uiInput.setOnKeyListener(this); // listen for hardware keyboard
    uiInput.addTextChangedListener(
        this); // listen for software keyboard through watching input box text
    uiInput.setOnEditorActionListener(
        this); // listen for software keyboard's “send” click. see onEditorAction()

    uiLines.setFocusable(false);
    uiLines.setFocusableInTouchMode(false);

    CopyPaste cp = new CopyPaste(activity, uiInput);
    uiInput.setOnLongClickListener(cp);
    uiLines.setOnItemLongClickListener(cp);

    return v;
  }
 public void initEditView() {
   // 处理回车键输入和返回键关闭
   input = (EditText) findViewById(R.id.editText1);
   input.getBackground().setAlpha(222);
   input.setOnKeyListener(
       new OnKeyListener() {
         @Override
         public boolean onKey(View v, int keyCode, KeyEvent event) {
           System.out.println("yzj111 onKey");
           // TODO Auto-generated method stub
           if (keyCode == KeyEvent.KEYCODE_ENTER) {
             System.out.println("yzj enter");
             try {
               test00TuringAndTrans();
             } catch (JSONException e) {
               e.printStackTrace();
             }
             return true;
           } else if (keyCode == KeyEvent.KEYCODE_BACK) {
             closeSelf();
           }
           return false;
         }
       });
   input.setInputType(InputType.TYPE_CLASS_TEXT);
   InputMethodManager imm =
       (InputMethodManager) tempContext.getSystemService(Context.INPUT_METHOD_SERVICE);
   imm.showSoftInput(this, 0);
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_add_players);

    llPlayers = (LinearLayout) findViewById(R.id.llPlayers);
    btnAddPlayer = (Button) findViewById(R.id.btnAddPlayer);
    btnStartGame = (Button) findViewById(R.id.btnStartGame);
    etName = (EditText) findViewById(R.id.etName);

    TextClearButtonHelper.set(etName, getResources().getDrawable(R.drawable.delete), this);

    btnAddPlayer.setEnabled(false);

    btnAddPlayer.setOnClickListener(this);
    btnStartGame.setOnClickListener(this);
    etName.setOnKeyListener(this);

    ThumbnailTextItemView view =
        new ThumbnailTextItemView(
            getBaseContext(),
            llPlayers.getChildCount(),
            getResources().getDrawable(R.drawable.golfer),
            "Me");

    llPlayers.addView(view);
  }
  private void FirstTimeSetup() {
    { // db export side
      EditText edtFilename = (EditText) findViewById(R.id.edtFilename);
      Button btnSave = (Button) findViewById(R.id.btnSaveDB);
      edtFilename.setOnEditorActionListener(this);
      edtFilename.setOnKeyListener(this);
      btnSave.setOnClickListener(this);
    }

    { // db import side
      ListView list = (ListView) findViewById(android.R.id.list);

      // search for all the files in our parent path
      File fDir = new File(MakeParentPath());
      if (fDir.exists()) {
        File children[] = fDir.listFiles();
        ArrayAdapter<DBPathEntry> adapter =
            new ArrayAdapter<DBPathEntry>(this, R.layout.simplelistitem_defaultcolor);
        for (int x = 0; x < children.length; x++) {
          String strName = children[x].getName();
          int ixWFLP = strName.lastIndexOf(".wflp");

          if (ixWFLP >= 0) {
            adapter.add(new DBPathEntry(children[x]));
          }
        }

        list.setAdapter(adapter);
        list.setOnItemClickListener(this);
        registerForContextMenu(list);
      } else {
        list.setEnabled(false);
      }
    }
  }
  /** Find our references to the objects in the xml layout */
  @Override
  protected void onFinishInflate() {
    super.onFinishInflate();

    et_name = (EditText) findViewById(R.id.et_name);
    btn_speichern = (Button) findViewById(R.id.btn_erstellen);

    spin_farbe = (Spinner) findViewById(R.id.spin_farbe);
    spin_form = (Spinner) findViewById(R.id.spin_figur);

    et_name.setOnKeyListener(
        new OnKeyListener() {
          public boolean onKey(View v, int keyCode, KeyEvent event) {
            return viewListener.onTastaturVerstecken(keyCode, event, et_name);
          }
        });

    btn_speichern.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            viewListener.onSpielerSpeichern(
                et_name, spin_farbe.getSelectedItem(), spin_form.getSelectedItem());
          }
        });
  }
  private View setupView(View view) {

    mButtonClear = (Button) view.findViewById(R.id.ButtonClear);
    if (null != mButtonClear) {
      mButtonClear.setOnClickListener(mClearButtonOnClick);
    }

    mButtonEnter = (Button) view.findViewById(R.id.ButtonEnter);
    if (null != mButtonEnter) {
      mButtonEnter.setOnClickListener(mEnterButtonOnClick);
    }

    mButtonDelete = (Button) view.findViewById(R.id.ButtonKeyboardInputDelete);
    if (null != mButtonDelete) {
      mButtonDelete.setOnClickListener(mDeleteButtonOnClick);
    }

    mEditTextInput = (EditText) view.findViewById(R.id.EditTextKeyboardInput);
    if (null != mEditTextInput) {
      mEditTextInput.setOnKeyListener(this);
      mEditTextInput.addTextChangedListener(this);
    }

    return view;
  }
Example #12
0
  @Override
  public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    setContentView(R.layout.login_screen);
    Log.i(TAG, "onCreate() called!");
    btnSign = (ImageButton) this.findViewById(R.id.btnSign);
    txtUsername = (EditText) this.findViewById(R.id.txtUsername);
    txtPassword = (EditText) this.findViewById(R.id.txtPassword);
    txtPassword.setOnKeyListener(
        new View.OnKeyListener() {

          public boolean onKey(View v, int keyCode, KeyEvent event) {
            if ((event.getAction() == KeyEvent.ACTION_DOWN)
                && (keyCode == KeyEvent.KEYCODE_ENTER)) {
              InputMethodManager imm =
                  (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
              imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
              v.findFocus();
              return true;
            }
            return false;
          }
        });

    // cbRem = (CheckBox) this.findViewById (R.id.cbRem);
    btnSign.setOnClickListener(mSignListener);
  }
  @Override
  public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    lv = (ListView) getView().findViewById(R.id.listView1);

    adapter =
        new MessageArrayAdapter(
            getActivity().getApplicationContext(), R.layout.listitem_discuss, msgs);

    lv.setAdapter(adapter);

    editText1 = (EditText) getView().findViewById(R.id.editText1);
    editText1.setOnKeyListener(
        new OnKeyListener() {
          public boolean onKey(View v, int keyCode, KeyEvent event) {
            // If the event is a key-down event on the "enter" button
            if ((event.getAction() == KeyEvent.ACTION_DOWN)
                && (keyCode == KeyEvent.KEYCODE_ENTER)) {
              // Perform action on key press
              Message msg =
                  ((MainActivity) ConversationFragment.this.getActivity())
                      .sendMessageToConversation(conversationName, editText1.getText().toString());
              if (msg != null) {
                adapter.add(new OneMessage(false, editText1.getText().toString()));
                editText1.setText("");
                return true;
              }
            }
            return false;
          }
        });
  }
Example #14
0
  private void setupViews() {

    mSearchEditText.addTextChangedListener(mTextWatcher);
    mSearchEditText.setImeActionLabel(getString(R.string.launch), EditorInfo.IME_ACTION_GO);
    mSearchEditText.setOnEditorActionListener(
        new TextView.OnEditorActionListener() {
          @Override
          public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {

            if (actionId == EditorInfo.IME_ACTION_GO) {
              Log.d("KEYBOARD", "ACTION_GO");
              return openFirstActivity();
            }
            return false;
          }
        });
    mSearchEditText.setOnKeyListener(
        new View.OnKeyListener() {
          public boolean onKey(View v, int keyCode, KeyEvent event) {
            if ((event.getAction() == KeyEvent.ACTION_DOWN)
                && (keyCode == KeyEvent.KEYCODE_ENTER)) {
              Log.d("KEYBOARD", "ENTER_KEY");
              return openFirstActivity();
            }
            return false;
          }
        });
    registerForContextMenu(mAppListView);

    ((GridView) mAppListView)
        .setOnScrollListener(
            new AbsListView.OnScrollListener() {
              @Override
              public void onScrollStateChanged(AbsListView view, int scrollState) {
                if (scrollState != SCROLL_STATE_IDLE) {
                  hideKeyboard();
                }
              }

              @Override
              public void onScroll(
                  AbsListView view,
                  int firstVisibleItem,
                  int visibleItemCount,
                  int totalItemCount) {}
            });
    //noinspection unchecked
    mAppListView.setAdapter(mArrayAdapter);

    mAppListView.setOnItemClickListener(
        new OnItemClickListener() {

          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            if (position >= mColumnCount) {
              launchActivity(mActivityInfos.get(position - mColumnCount));
            }
          }
        });
  }
Example #15
0
  private void InitControl() {
    find_user_panel = (RelativeLayout) findViewById(R.id.find_user_panel);
    tab_interested_friend = (RadioGroup) findViewById(R.id.tab_interested_friend);
    search_layout = (RelativeLayout) findViewById(R.id.search_layout);
    btn_Addfriend = (Button) findViewById(R.id.btn_Addfriend);
    btn_Back = (Button) findViewById(R.id.btn_Back);
    list_user = (ListView) findViewById(R.id.lst_friend);
    txt_find_user = (EditText) findViewById(R.id.txt_find_user);
    btn_FindUser = (Button) findViewById(R.id.btn_find_user);
    title_view = (TextView) findViewById(R.id.feature_title_txt);
    loading_panel = (RelativeLayout) findViewById(R.id.loading_panel);
    btn_Clear = (Button) findViewById(R.id.btn_Clear_find_user);
    empty_layout = (RelativeLayout) findViewById(R.id.empty_layout);
    empty_icon = (ImageView) findViewById(R.id.empty_icon);
    empty_label = (TextView) findViewById(R.id.empty_label);

    title_view.setText(R.string.find_friend);
    find_user_panel.setVisibility(View.VISIBLE);
    tab_interested_friend.setVisibility(View.GONE);
    search_layout.setVisibility(View.GONE);
    btn_Addfriend.setVisibility(View.GONE);
    list_user.setVisibility(View.GONE);
    btn_Back.setOnClickListener(onbackListener);
    btn_FindUser.setOnClickListener(onFindListener);
    btn_Clear.setOnClickListener(onClearListener);
    txt_find_user.setOnKeyListener(ontxtFindListener);
  }
Example #16
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    readToDoItems();
    aa = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, todoItems);
    ListView mListView = (ListView) findViewById(R.id.list_view);
    mListView.setAdapter(aa);
    registerForContextMenu(mListView);

    final EditText mEditText = (EditText) findViewById(R.id.add_item_text);
    mEditText.setOnKeyListener(
        new View.OnKeyListener() {
          @Override
          public boolean onKey(View v, int keyCode, KeyEvent event) {
            if (event.getAction() == KeyEvent.ACTION_DOWN)
              if ((keyCode == KeyEvent.KEYCODE_DPAD_CENTER)
                  || (keyCode == KeyEvent.KEYCODE_ENTER)) {
                todoItems.add(0, mEditText.getText().toString());
                aa.notifyDataSetChanged();
                mEditText.setText("");
                return true;
              }
            return false;
          }
        });
  }
Example #17
0
  // TEST
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_create_team);
    // Test
    editTeam = (EditText) findViewById(R.id.editTeam);
    editTeam.setOnKeyListener(
        new OnKeyListener() {
          public boolean onKey(View v, int keyCode, KeyEvent event) {
            // If the event is a key-down event on the "enter" button
            if ((event.getAction() == KeyEvent.ACTION_DOWN)
                && (keyCode == KeyEvent.KEYCODE_ENTER)) {
              // Perform action on key press
              create(v);
              return true;
            }
            return false;
          }
        });
    lv = (ListView) findViewById(R.id.listView1);
    // End
    // Database Text Box Initialization
    db = new SqliteHelper(this.getApplicationContext());
    // Button create = (Button)findViewById(R.id.create);

    populateListViews();
    registerClickCallback();
    registerForContextMenu(lv);
    // DB
  }
Example #18
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
      WebView.setWebContentsDebuggingEnabled(true);
    }
    setContentView(R.layout.activity_webview_browser);
    mUrlBar = (EditText) findViewById(R.id.url_field);
    mUrlBar.setOnKeyListener(
        new OnKeyListener() {
          public boolean onKey(View view, int keyCode, KeyEvent event) {
            if (keyCode == KeyEvent.KEYCODE_ENTER && event.getAction() == KeyEvent.ACTION_UP) {
              loadUrlFromUrlBar(view);
              return true;
            }
            return false;
          }
        });

    createAndInitializeWebView();

    String url = getUrlFromIntent(getIntent());
    if (url == null) {
      // Make sure to load a blank page to make it immediately inspectable with
      // chrome://inspect.
      url = "about:blank";
    }
    setUrlBarText(url);
    setUrlFail(false);
    loadUrlFromUrlBar(mUrlBar);
  }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_login, container, false);
    mLoginButton = view.findViewById(R.id.btn_login);
    mEmailView = (EditText) view.findViewById(R.id.txt_email);
    mPasswordView = (EditText) view.findViewById(R.id.txt_password);
    mEmailView.addTextChangedListener(this);
    mPasswordView.addTextChangedListener(this);

    mPasswordView.setOnKeyListener(
        new OnKeyListener() {
          @Override
          public boolean onKey(View v, int keyCode, KeyEvent event) {
            if (keyCode == KeyEvent.KEYCODE_ENTER && event.getAction() == KeyEvent.ACTION_DOWN) {
              ((LoginActivity) getActivity()).login(null);
              return true;
            } else {
              return false;
            }
          }
        });

    updateLoginButtonEnabledState();
    return view;
  }
Example #20
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_password);

    EditText etPassword = (EditText) findViewById(R.id.etPassword);
    etPassword.setOnKeyListener(
        new View.OnKeyListener() {
          @Override
          public boolean onKey(View view, int i, KeyEvent keyEvent) {
            if (keyEvent.getAction() == KeyEvent.ACTION_DOWN) {
              switch (i) {
                case KeyEvent.KEYCODE_ENTER:
                  checkPassword(null);
                  return true;
                default:
                  break;
              }
            }
            return false;
          }
        });

    createFolders();

    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
    if (prefs.getString("password_text", "").equals("")) {
      unlock();
    }
  }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // TODO Auto-generated method stub

    // userid = savedInstanceState.getString("userid");

    View view = inflater.inflate(R.layout.messages_content_frag, container, false);

    lvMsg = (ListView) view.findViewById(R.id.lv_msg_frag);

    View view1 = inflater.inflate(R.layout.edit_text_frag, container, false);

    et_msg = (EditText) view1.findViewById(R.id.et_msg);
    // Button bt_send_msg  = (Button) view1.findViewById(R.id.bt_send_msg);
    session = new Session(getActivity());
    msgfrnd = new ArrayList<MsgInfo>();
    start = 0;
    adapter = new MessageSendAdapter(msgfrnd, getActivity());
    lvMsg.setAdapter(adapter);
    lvMsg.setOnScrollListener(new EndlessScrollListener());
    lvMsg.setStackFromBottom(true);
    et_msg.setOnKeyListener(
        new OnKeyListener() {

          @Override
          public boolean onKey(View v, int keyCode, KeyEvent event) {
            // TODO Auto-generated method stub
            System.out.println("Working !!!");
            if (event.getAction() == KeyEvent.ACTION_DOWN) {
              switch (keyCode) {
                case KeyEvent.KEYCODE_DPAD_CENTER:
                case KeyEvent.KEYCODE_ENTER:
                  Log.e("Seding Chat", "Sending CHat");
                  new SendChat().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);

                  return true;
                default:
                  break;
              }
            }
            return false;
          }
        });
    /*
    bt_send_msg.setOnClickListener(new OnClickListener() {

    	@Override
    	public void onClick(View v) {
    		// TODO Auto-generated method stub
    		new SendChat().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
    	}
    });

    */
    new fetchMsgFriend().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);

    return view1;
  }
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    getPrefs();
    savePrefs();
    pwdText = (EditText) findViewById(R.id.passwordText1);
    enableCheckBox = (CheckBox) findViewById(R.id.enableCheckBox);
    timeOutText = (EditText) findViewById(R.id.timeOutText);
    useGPSCheckBox = (CheckBox) findViewById(R.id.useGPSCheckBox);
    setFormValues();

    // Enable the testButton
    Button testButton = (Button) findViewById(R.id.testButton);
    testButton.setOnClickListener(this);

    // Save the data when the enter or TAB key is pressed
    pwdText.setOnKeyListener(
        new View.OnKeyListener() {
          public boolean onKey(View v, int keyCode, KeyEvent event) {
            if ((event.getAction() == KeyEvent.ACTION_DOWN)
                && ((keyCode == KeyEvent.KEYCODE_ENTER) || (keyCode == KeyEvent.KEYCODE_TAB))) {
              msgBox("Saving Data");
              getFormValues();
              savePrefs();
              return true;
            }
            return false;
          }
        });

    pwdText.setOnFocusChangeListener(
        new View.OnFocusChangeListener() {
          public void onFocusChange(View v, boolean hasFocus) {
            msgBox("Saving Data");
            getFormValues();
            savePrefs();
          }
        });

    enableCheckBox.setOnCheckedChangeListener(
        new OnCheckedChangeListener() {
          public void onCheckedChanged(CompoundButton v, boolean b) {
            msgBox("Saving Data");
            getFormValues();
            savePrefs();
          }
        });

    useGPSCheckBox.setOnCheckedChangeListener(
        new OnCheckedChangeListener() {
          public void onCheckedChanged(CompoundButton v, boolean b) {
            msgBox("Saving Data");
            getFormValues();
            savePrefs();
          }
        });
  }
  public void showTransferDialog(final String action) {
    Log.i(TAG, "showing it");

    // get prompts.xml view
    LayoutInflater li = LayoutInflater.from(this);
    View promptsView = li.inflate(R.layout.transfer_prompt, null);

    AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
    alertDialogBuilder.setView(promptsView);

    userInput = (EditText) promptsView.findViewById(R.id.transferDialogInput);
    userInput.setOnKeyListener(this);
    valueDisplay = (TextView) promptsView.findViewById(R.id.transferText);
    regionSpinner = (Spinner) promptsView.findViewById(R.id.transferRegion);
    // Create an ArrayAdapter using the string array and a default
    // spinner layout
    ArrayAdapter<CharSequence> adapter =
        ArrayAdapter.createFromResource(
            this, R.array.regions_array, android.R.layout.simple_spinner_item);
    // Specify the layout to use when the list of choices appears
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    // Apply the adapter to the spinner
    regionSpinner.setAdapter(adapter);

    regionSpinner.setOnItemSelectedListener(this);

    // set dialog message
    alertDialogBuilder
        .setCancelable(true)
        .setPositiveButton(
            "OK",
            new DialogInterface.OnClickListener() {

              public void onClick(DialogInterface dialog, int id) {

                result = new String(userInput.getText() + "");
                transferRegion = new String(regionSpinner.getSelectedItem().toString());
                Log.i(TAG, "the result: " + result);

                setTransferMessage();
                send(MAIN_TOPIC, transferMessage.toString(), user + "-transfer");
              }
            })
        .setNegativeButton(
            "Cancel",
            new DialogInterface.OnClickListener() {
              public void onClick(DialogInterface dialog, int id) {
                dialog.cancel();
              }
            });

    // create alert dialog
    AlertDialog alertDialog = alertDialogBuilder.create();

    // show it
    Log.i(TAG, "Before Show");
    alertDialog.show();
  }
Example #24
0
  /**
   * 标签策略
   *
   * @param tags 标签输入
   * @param hotTagsLayout 热门标签列表
   * @param showTagsLayout 显示已加入的标签
   */
  public TagInputPolicy(
      Context context, EditText tags, AutoWrapLayout hotTagsLayout, ViewGroup showTagsLayout) {
    mContext = context.getApplicationContext();
    mShowTagsGroup = showTagsLayout;
    mHotTagsGroup = hotTagsLayout;
    mTags = tags;

    mTagsHint = mTags.getHint().toString();

    mTags.setOnEditorActionListener(
        new TextView.OnEditorActionListener() {
          @Override
          public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_DONE) {
              addTagView(mTags.getText().toString());
              return true;
            }
            return false;
          }
        });

    mTags.setOnKeyListener(
        new View.OnKeyListener() {
          @Override
          public boolean onKey(View v, int keyCode, KeyEvent event) {
            if (keyCode == KeyEvent.KEYCODE_DEL && event.getAction() == KeyEvent.ACTION_DOWN) {
              if (mTags.getText().length() == 0) {
                if (mInputTags.size() > 0) {
                  String deleteTag = mInputTags.remove(mInputTags.size() - 1);
                  deleteTagView(deleteTag);
                  checkEditHint();
                }
              }
            }
            return false;
          }
        });

    mTags.addTextChangedListener(
        new TextWatcher() {
          @Override
          public void beforeTextChanged(CharSequence s, int start, int count, int after) {}

          @Override
          public void onTextChanged(CharSequence s, int start, int before, int count) {
            String pre = s.subSequence(0, start).toString();
            String end = s.subSequence(start, start + count).toString();
            // 输入空格也执行添加标签功能
            if (" ".equals(end)) {
              addTagView(pre);
            }
          }

          @Override
          public void afterTextChanged(Editable s) {}
        });
  }
  @Override
  public void onCreate(Bundle bundle) {
    super.onCreate(bundle);

    BootstrapApplication.component().inject(this);

    accountManager = AccountManager.get(this);

    final Intent intent = getIntent();
    email = intent.getStringExtra(PARAM_USERNAME);
    authTokenType = intent.getStringExtra(PARAM_AUTHTOKEN_TYPE);
    confirmCredentials = intent.getBooleanExtra(PARAM_CONFIRM_CREDENTIALS, false);

    requestNewAccount = email == null;

    setContentView(layout.login_activity);

    ButterKnife.bind(this);

    emailText.setAdapter(
        new ArrayAdapter<String>(this, simple_dropdown_item_1line, userEmailAccounts()));

    passwordText.setOnKeyListener(
        new OnKeyListener() {

          public boolean onKey(final View v, final int keyCode, final KeyEvent event) {
            if (event != null
                && ACTION_DOWN == event.getAction()
                && keyCode == KEYCODE_ENTER
                && signInButton.isEnabled()) {
              handleLogin(signInButton);
              return true;
            }
            return false;
          }
        });

    passwordText.setOnEditorActionListener(
        new OnEditorActionListener() {

          public boolean onEditorAction(
              final TextView v, final int actionId, final KeyEvent event) {
            if (actionId == IME_ACTION_DONE && signInButton.isEnabled()) {
              handleLogin(signInButton);
              return true;
            }
            return false;
          }
        });

    emailText.addTextChangedListener(watcher);
    passwordText.addTextChangedListener(watcher);

    final TextView signUpText = (TextView) findViewById(id.tv_signup);
    signUpText.setMovementMethod(LinkMovementMethod.getInstance());
    signUpText.setText(Html.fromHtml(getString(string.signup_link)));
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.login_two_factor_auth);

    accountManager = AccountManager.get(this);

    ViewFinder finder = new ViewFinder(this);
    otpCodeText = finder.find(R.id.et_otp_code);

    final Intent intent = getIntent();
    username = intent.getStringExtra(PARAM_USERNAME);
    password = intent.getStringExtra(PARAM_PASSWORD);

    TextView signupText = finder.find(R.id.tv_signup);
    signupText.setMovementMethod(LinkMovementMethod.getInstance());
    signupText.setText(Html.fromHtml(getString(R.string.signup_link_two_factor_auth)));

    TextWatcher watcher =
        new TextWatcherAdapter() {

          @Override
          public void afterTextChanged(Editable gitDirEditText) {
            updateEnablement();
          }
        };
    otpCodeText.addTextChangedListener(watcher);

    otpCodeText.setOnKeyListener(
        new View.OnKeyListener() {

          @Override
          public boolean onKey(View v, int keyCode, KeyEvent event) {
            if (event != null
                && ACTION_DOWN == event.getAction()
                && keyCode == KEYCODE_ENTER
                && loginEnabled()) {
              handleLogin();
              return true;
            } else return false;
          }
        });

    otpCodeText.setOnEditorActionListener(
        new TextView.OnEditorActionListener() {

          @Override
          public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == IME_ACTION_DONE && loginEnabled()) {
              handleLogin();
              return true;
            }
            return false;
          }
        });
  }
 @Override
 public void onSanitizerCreated(ISanitizer sanitizer) {
   Log.i("Sanitizer", "Sanitizer created");
   this.sanitizer = sanitizer;
   mCallbacks.setSanitizerCallbacks(watcher); // call after Sanitizer initialization
   watcher = new ScriptureWatcher(sanitizer);
   watcher.setBible(bible);
   noteText.addTextChangedListener(watcher);
   noteText.setOnKeyListener(keyListener);
 }
  private TextView initStatusBar(long providerId, boolean showEdit) {

    EditText statusEdit = (EditText) findViewById(R.id.statusEdit);
    statusEdit.setVisibility(View.GONE);
    TextView statusView = (TextView) findViewById(R.id.statusView);
    statusView.setVisibility(View.GONE);

    if (showEdit) {

      statusEdit.setVisibility(View.VISIBLE);
      statusEdit.setOnKeyListener(
          new OnKeyListener() {
            public boolean onKey(View v, int keyCode, KeyEvent event) {
              if (KeyEvent.ACTION_DOWN == event.getAction()) {
                switch (keyCode) {
                  case KeyEvent.KEYCODE_DPAD_CENTER:
                  case KeyEvent.KEYCODE_ENTER:
                    updateStatusText();
                    return true;
                }
              }
              return false;
            }
          });

      statusEdit.setOnFocusChangeListener(
          new View.OnFocusChangeListener() {
            public void onFocusChange(View v, boolean hasFocus) {
              if (!hasFocus) {
                updateStatusText();
              }
            }
          });

      return statusEdit;
    } else {
      if (mPresence != null) {
        statusView.setText(mPresence.getStatusText());
      }

      statusView.setVisibility(View.VISIBLE);

      statusView.setOnClickListener(
          new OnClickListener() {

            @Override
            public void onClick(View v) {
              mStatusBar = initStatusBar(mProviderId, true);
            }
          });

      return statusView;
    }
  }
Example #29
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.songlist);

    availableSongsListView = (ListView) findViewById(R.id.playlistAvailableSongsListView);
    filterEditText = (EditText) findViewById(R.id.playlistFilterEditText);
    clearButton = (Button) findViewById(R.id.clearButton);

    registerForContextMenu(availableSongsListView);
    availableSongsListView.setOnItemClickListener(
        new OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            view.showContextMenu();
          }
        });
    availableSongsListView.setAdapter(new SongAdapter(this, new Song[] {}));

    filterEditText.setOnKeyListener(
        new OnKeyListener() {
          @Override
          public boolean onKey(View v, int keyCode, KeyEvent event) {
            if (event.getKeyCode() == KeyEvent.KEYCODE_ENTER) {
              updateAvailableSongsListView();
              InputMethodManager imm =
                  (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
              imm.hideSoftInputFromWindow(filterEditText.getWindowToken(), 0);
              return true;
            }
            return false;
          }
        });

    clearButton.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            filterEditText.setText("");
            updateAvailableSongsListView();
          }
        });

    INSTANCE = this;

    bindService(new Intent(SongList.this, Player.class), playerConnection, BIND_AUTO_CREATE);

    if (!Player.isExternalStorageMounted()) {
      setContentView(R.layout.songlist_notmounted);
      return;
    }
  }
Example #30
0
 private void setupSearchBox() {
   etSearchBox.setOnKeyListener(
       new OnKeyListener() {
         public boolean onKey(View v, int keyCode, KeyEvent event) {
           if ((event.getAction() == KeyEvent.ACTION_DOWN)
               && (keyCode == KeyEvent.KEYCODE_ENTER || keyCode == KeyEvent.KEYCODE_DPAD_CENTER)) {
             search(v, 0);
             return true;
           }
           return false;
         }
       });
 }