Skip to content

Commit

Permalink
Add getText and setText
Browse files Browse the repository at this point in the history
  • Loading branch information
mancj committed Aug 21, 2016
1 parent 927b451 commit a7b3c51
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 7 deletions.
1 change: 0 additions & 1 deletion .idea/.name

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/vcs.xml

This file was deleted.

3 changes: 3 additions & 0 deletions app/src/main/java/com/mancj/example/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.util.Log;
import android.view.Gravity;
import android.view.View;
import android.support.design.widget.NavigationView;
Expand Down Expand Up @@ -32,6 +33,8 @@ protected void onCreate(Bundle savedInstanceState) {
searchBar = (MaterialSearchBar) findViewById(R.id.searchBar);
searchBar.setOnSearchActionListener(this);
searchBar.inflateMenu(R.menu.main);
searchBar.setText("Привет мир");
Log.d("LOG_TAG", getClass().getSimpleName() + ": text " + searchBar.getText());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,14 @@ public void setSpeechMode(boolean speechMode){
}
}

/**
* True if MaterialSearchBar is in speech mode
* @return speech mode
*/
public boolean isSpeechModeEnabled(){
return speechMode;
}

/**
* Check if search bar is in edit mode
* @return true if search bar is in edit mode
Expand Down Expand Up @@ -357,6 +365,22 @@ public void setNavButtonEnabled(boolean navButtonEnabled) {
}
}

/**
* Set search text
* @param text text
*/
public void setText(String text){
searchEdit.setText(text);
}

/**
* Get search text
* @return text
*/
public String getText(){
return searchEdit.getText().toString();
}

private boolean listenerExists(){
return onSearchActionListener != null;
}
Expand Down

0 comments on commit a7b3c51

Please sign in to comment.