List of usage examples for android.widget CompoundButton toString
public String toString()
From source file:com.sentaroh.android.TextFileBrowser.FileViewerFragment.java
private void setFindStringListener() { final Button btnFind = (Button) mMainView.findViewById(R.id.activity_browser_main_search_btn); final EditText et_find_string = (EditText) mMainView.findViewById(R.id.activity_browser_main_search_text); final CheckBox cb_case = (CheckBox) mMainView .findViewById(R.id.activity_browser_main_search_case_sensitive); final TextView main_msg = (TextView) mMainView.findViewById(R.id.activity_browser_main_msg); cb_case.setChecked(mViewedFile.searchCaseSensitive); cb_case.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override/*from w w w. j a v a 2s. co m*/ public void onCheckedChanged(CompoundButton arg0, boolean arg1) { mViewedFile.searchCaseSensitive = arg1; } }); et_find_string.setText(mViewedFile.searchString); if (mViewedFile.searchString.equals("")) btnFind.setEnabled(false); et_find_string.addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(Editable arg0) { if (arg0.toString().equals("")) btnFind.setEnabled(false); else btnFind.setEnabled(true); } @Override public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { } @Override public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { main_msg.setText(""); main_msg.setVisibility(TextView.GONE); } }); mTextListView.setOnScrollListener(new OnScrollListener() { @Override public void onScroll(AbsListView arg0, int arg1, int arg2, int arg3) { } @Override public void onScrollStateChanged(AbsListView arg0, int arg1) { // Log.v("","onScrollStateChanged, arg1="+arg1); if (arg1 == AbsListView.OnScrollListener.SCROLL_STATE_TOUCH_SCROLL || arg1 == AbsListView.OnScrollListener.SCROLL_STATE_FLING) mViewedFile.findPosIsValid = false; } }); btnFind.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // InputMethodManager imm=(InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); // imm.hideSoftInputFromWindow(et_find_string.getWindowToken(),0); mViewedFile.searchString = et_find_string.getText().toString(); int start_pos = 0; if (mViewedFile.findResultPos == -1 || !mViewedFile.findPosIsValid) { //???? start_pos = mTextListView.getFirstVisiblePosition(); } else {//???? //?????????? start_pos = mViewedFile.findResultPos + 1; } mViewedFile.findPosIsValid = true; mViewedFile.findResultPos = mTextListAdapter.findString( FileViewerAdapter.TEXT_BROWSER_BROWSE_MODE_CHAR, start_pos, mViewedFile.searchString, cb_case.isChecked()); if (mViewedFile.findResultPos != -1) { // Log.v("","fp="+mViewedFileListItem.findResultPos); if (mViewedFile.findResultPos > 0) { mTextListView.setSelection(mViewedFile.findResultPos - 1); } else { mTextListView.setSelection(mViewedFile.findResultPos); } main_msg.setText(""); main_msg.setVisibility(TextView.GONE); } else { mViewedFile.findResultPos = start_pos;//?? mTextListView.setSelected(false); main_msg.setText(mContext.getString(R.string.msgs_text_browser_search_string_not_found)); main_msg.setVisibility(TextView.VISIBLE); } } }); // if (mViewedFile.searchEnabled) { // if (mViewedFile.browseMode==FileViewerAdapter.TEXT_BROWSER_BROWSE_MODE_CHAR) { // btnFind.setVisibility(Button.VISIBLE); // et_find_string.setVisibility(EditText.VISIBLE); // cb_case.setVisibility(CheckBox.VISIBLE); // } else { // btnFind.setVisibility(Button.GONE); // et_find_string.setVisibility(EditText.GONE); // cb_case.setVisibility(CheckBox.GONE); // } // } }