android: display a toast message after clicking on edittext - android-edittext

I don't know if this is possible but I am looking for a way to display a toast message after clicking on edittext.
I tried this but it didn't work:
editText1.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Toast.makeText(RectangleWidth.this, "message here", Toast.LENGTH_SHORT).show();
return;
}
});

First you should set the edit text to android:focusable="false" in your xml code

Maybe it's not the best solution from a UI point of view. See here: Android EditText onClickListener

Related

Drillup Button Click Listener - Vaadin Charts

I know that drillup button works on the client side, but is there any way to know when that button is clicked?
In the ColumnWithLazyMultiLevelDrilldown class you can see example of using ChartDrillupListener.
Chart chart = new Chart(ChartType.COLUMN);
chart.addChartDrillupListener(new ChartDrillupListener() {
#Override
public void onDrillup(ChartDrillupEvent event) {
log("ChartDrillupEvent");
}
});

EditText with multiple lines option accepts enter key as value android

This might be silly question ever but still couldn't find solution. I have EditText with multiple line option on press of enter key in softkey moves to next lines and when clicked on post button to post the content of edittext the value has 2 enter option[i.e 2 blank lines]. before posting i do check for
blank and null value but this doesn't prevent posting enter value.
if (!(story_write_text.getText().toString().equals(""))||!(story_write_text.getText().toString().equals(null)))
my question: how to check edittext value if there are only enter values so that i can prevent from posting blank enter value to server.
here's my edittext xml code:
<EditText
android:id="#+id/story_write_text"
style="#android:style/TextAppearance.Small"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/edit_text"
android:gravity="left"
android:hint="Write a comment"
android:inputType="textCapSentences"
android:padding="5dp"
android:textSize="15sp" />
just add android:inputType="textPersonName"
to the EditText it will stop it from pressing enter
If it not working then use below code
I would subclass the widget and override the key event handling in order to block the Enter key:
class MyTextView extends EditText
{
...
#Override
public boolean onKeyDown(int keyCode, KeyEvent event)
{
if (keyCode==KeyEvent.KEYCODE_ENTER)
{
// Just ignore the [Enter] key
return true;
}
// Handle all other keys in the default way
return super.onKeyDown(keyCode, event);
}
}

blackberry jre4.5, highlight URL

I have an object that extends Field, I use the paint method to draw text using graphics.drawText. I want to have url, and when the user scrolls over it, it gets highlighted. and when clicked it invokes the browser to the link.
like the normal behaviour in the blackberry.
Please direct me.
Thanks,
Aly
You can use LabelField as a button like this:
LabelField labelField = new LabelField("label to show",FOCUSABLE){
protected boolean invokeAction(int action) {
if ( action == ACTION_INVOKE){
// browsing...
}
return super.invokeAction( action );
}
};

Can i call dialog box on popup screen in blackberry?

In my blackberry application i make one popup screen which is popup on click of menu item. on that popup screen i took one button. Now i want to show alert dialog box on click of that button.How to do this ?Plz tell me.
You can do like this.
public void fieldChanged(Field field, int context)
{
if(field.equals(your button object))
{
Dialog.alert("Your message");
}
}

Blackberry screen navigation

I want to know how to go from one screen to another by clicking a button that I have added to a MainScreen. I mean just like we do in the Android onClick event for a button - start another startActivity.
In the event handler for the button click, just "push" the screen that you want to appear next, and it will be pushed to the top of the screen stack. For example:
UiApplication.getUiApplication().pushScreen(nextScreen);
This will be better, using FieldChangeListener
button.setChangeListener(new FieldChangeListener()
{
public void fieldChanged(Field field, int context)
{
UiApplication.getUiApplication().pushScreen(new NextScreen());
}
});
This is the alternative way than using,
UiApplication.getUiApplication.involeLater()
{};

Resources