I am using celltable , GWT2.3.0
How to determine which button is clicked by user ?
Is there any way to find out NEXT,PREV,LAST & FIRST button clicked ?
Any help or guidance in this matter would be appreciated
Well the easist way I see right now, is write your own Simple pager and overwrite the "lastPage", "lastPageStart", "nextPage" and "previousPage" functions.
In my test example, which I build in ~5min it lookes like this:
public class Ui_mySimplePager extends SimplePager {
public Ui_mySimplePager(TextLocation center, Resources pagerResources,
boolean b, int i, boolean c) {
super(center, pagerResources, b, i, c);
}
#Override
public void lastPage() {
Window.alert("lastPage");
super.lastPage();
}
#Override
public void lastPageStart() {
Window.alert("lastPageStart");
super.lastPageStart();
}
#Override
public void nextPage() {
Window.alert("nextPage");
super.nextPage();
}
#Override
public void previousPage() {
Window.alert("previousPage");
super.previousPage();
}
}
Related
I'm trying to implement app like Instagram where user can like and share but when he press on a button (like image heart) .
///interface to get position
#Override
public void onitemclick(int position) {
position_of_image=position;
int num1=uploads.get(position_of_image).getNumber_likes();
uploads.get(position_of_image).setNumber_likes(num1+1);
String id=uploads.get(position_of_image).getId();
int number= uploads.get(position_of_image).getNumber_likes();
String name= uploads.get(position_of_image).getName();
String url=uploads.get(position_of_image).getImageUrl();
//updating the tables
Map<String,Object> map=new HashMap<>();
map.put(id,new Upload(name,url,number,id));
// mDatabaseRef.child(id).child("number_likes").setValue(number);
uploads.clear();
mDatabaseRef.updateChildren(map);
mRecyclerView.smoothScrollToPosition(position_of_image);
}
**and this is my interface on click in my adapter I want to make the like btn is red it done but disappears quickly **
#Override
public void onClick(View v) {
if (mlistener!=null){
int position=getAdapterPosition();
if (position!=RecyclerView.NO_POSITION){
mlistener.onitemclick(position);
}
like.setImageResource(R.drawable.red_heart);
}
public interface onlikeclic{
void onitemclick(int position);
}
public void setonitemclicklistener(onlikeclic listener){
mlistener=listener;
}
On item click, use call RecyclerView's smoothScrollToPosition(0) method.
You can see an example in this answer.
I created my own eclipse view and is trying to add a link in a popup menu. I am able to add the link but it's grayed out. I wonder how I can activate the link. I just want to be able to click on the link and trigger run(). DeleteAction is the class i want to trigger. SegmentReferencesView is the view I created. Would be very thankful for help.
This is from the plugin.xml:
<extension point="org.eclipse.ui.popupMenus">
<viewerContribution
id="se.test.views.categories.segmentreferences.ui.views"
targetID="se.test.views.categories.segmentreferences.ui.views.SegmentReferencesView">
<action
class="se.test.views.categories.segmentreferences.ui.views.DeleteAction"
enablesFor="1"
icon="icons/Delete.gif"
id="se.test.views.categories.segmentreferences.ui.views.DeleteReferenceAction"
label="Do action"
menubarPath="additions-ext">
</action>
</viewerContribution>
This is the Java class:
public class DeleteAction implements IViewActionDelegate {
#Override
public void init(org.eclipse.ui.IViewPart view) {
super.init(view);
};
#Override
public void run(IAction action) {
}
}
Your view must set the view site 'Selection Provider'. This is used by the menu system to find out what is selected. If you are using a TableViewer or TreeViewer you can just do:
getSite().setSelectionProvider(viewer);
in the view code immediately after you have created viewer (which should be the TableViewer or TreeViewer).
I managed to get the link to work by extending org.eclipse.core.commands.AbstractHandler in the DeleteAction class. I don't know if this is the best way to do it but it's working for now.
public class DeleteAction extends AbstractHandler implements IViewActionDelegate {
#Override
public void init(org.eclipse.ui.IViewPart view) {
// Not used
}
#Override
public void run(IAction action) {
System.out.println("run"); //$NON-NLS-1$
}
#Override
public void selectionChanged(IAction action, ISelection selection) {
// Not used
}
#Override
public Object execute(ExecutionEvent event) throws ExecutionException {
return null;
}
}
I am using android eclipse for programming.
I will use this basic calculation to fit to what I want to happen.
Here:
I got two buttons add and minus. if i press add it will obviously call the method add.
But my problem is. if I will keep pressing add button. It will keep adding multiple times and
if I will click 2 buttons at the same time it will also do add and minus. What I want is that
if i click both button at the same time there's priority that add button will execute first
and the minus button will not send data.
Add(){
a = b + c;
}
Minus(){
a = b - c;
}
public void add(View view){
Add();
}
public void subtract(View view){
Minus();
}
Just set button_minus.setClickable(false); in Add method and
button_add.setClickable(false); in Minus method. Then enable them back.
try:
private boolean isAddButtonPressed;
private void setListener(){
buttonAdd.setOnTouchListener(new View.OnTouchListener() {
#Override
public boolean onTouch(View v, MotionEvent event) {
if(event.getAction() == MotionEvent.ACTION_DOWN)
isAddButtonPressed = true;
else
isAddButtonPressed = false;
return false;
}
});
}
public void add(View view){
doMath(true);
}
public void subtract(View view){
if(!isAddButtonPressed)
doMath(false);
}
// "synchronized" means that this method can ran only one time at a time
private synchronized void doMath(boolean isAdd) {
if(isAdd) {
Add();
} else {
Minus();
}
}
I'm trying to get a character count of an EditText (numberRoom). When user would insert 8 characters button should switch from state Disabled and color 0xBBFFFFFF to state Enabled and color 0xFFFFFFFF.
I've tried few method and I think the best one I've found is that one below. However button has state Enabled and color 0xFFFFFFFF even when input is empty. What's wrong there?
public class Join_room_screen extends Activity {
EditText numberRoom;
Button goToRoom;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.joinroom);
numberRoom = (EditText) findViewById(R.id.roomNumber);
goToRoom = (Button) findViewById(R.id.goToRoom);
TextWatcher watcher = new LocalTextWatcher();
goToRoom.addTextChangedListener(watcher);
updateButtonState();
}
void updateButtonState() {
boolean enabled = checkEditText(numberRoom);
goToRoom.setBackgroundColor(0xFFFFFFFF);
goToRoom.setEnabled(enabled);
}
private boolean checkEditText(EditText edit) {
return ((edit.getText().toString()).length() == 8 );
}
private class LocalTextWatcher implements TextWatcher {
public void afterTextChanged(Editable s) {
updateButtonState();
}
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
}
}
However in properties I've
In this function the enabled variable is never used so the background colour and enabled states are always set.
void updateButtonState() {
boolean enabled = checkEditText(numberRoom);
goToRoom.setBackgroundColor(0xFFFFFFFF);
goToRoom.setEnabled(enabled);
}
I would replace with something like
void updateButtonState() {
boolean enabled = checkEditText(numberRoom);
if (enabled) {
goToRoom.setBackgroundColor(0xFFFFFFFF);
goToRoom.setEnabled(enabled);
} else {
//change them back to disabled state
}
}
You have one problem in updateButtonState(), it always sets one color to your button. I see, you have already solved that.
The other problem is that you set TextChangeListener not to an EditText, but somewhy to a Button.
The EditText should be watched.
numberRoom.addTextChangedListener(watcher);
instead of
goToRoom.addTextChangedListener(watcher);
I've got a PopupDateField with a ValueChangeListener.
Is there a way to differentiate if the Event was fired from an .setValue()-Call or an User-Input?
I want the Event to be excuted only if the user changes the value, not if it was changed by program.
I've made a dirty Workaround by removing the ValueChangListener before setting a new Value and adding it afterwards, but I'm thankfull for better solutions...
private static void setDateFieldValue(final PopupDateField dateField, Date value) {
Collection<Property.ValueChangeListener> listeners = (Collection<Property.ValueChangeListener>)dateField.getListeners(Property.ValueChangeEvent.class);
listeners.forEach(new Consumer<Property.ValueChangeListener>() {
#Override
public void accept(Property.ValueChangeListener listener) {
dateField.removeValueChangeListener(listener);
}
});
dateField.setValue(value);
listeners.forEach(new Consumer<Property.ValueChangeListener>() {
#Override
public void accept(Property.ValueChangeListener listener) {
dateField.addValueChangeListener(listener);
}
});
}