We are trying to set textDirection "rtl" programatically.
But, when we set it to "ltr" then on button click changing textDirection to "rtl" is not working.
Here is my code :
edtUSername.setTextDirection(View.TEXT_DIRECTION_LTR);
btnSubmit.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
edtUSername.setTextDirection(View.TEXT_DIRECTION_RTL);
}
});
And this is not working only in api level 17.
Related
How i said in the title onClick event doesn't work with JellyBean devices.
Here there is the code
((Button)view.findViewById(R.id.more_questions)).setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
LinearLayout linearLayout= (LinearLayout)view.findViewById(R.id.linear);
EditText radioButton= new EditText(getContext());
radioButton.setText("Inserisci la nuova domanda");
radioButton.setSelectAllOnFocus(true);
domande.add(radioButton);
linearLayout.addView(radioButton);
}
});
Can someone fix my problem?? Becouse with the higher api's Versions there isn't this problem
I have a simple android webview app and I want to add zoom in button only,
I added the zoom in button in the graphical layout:
but how can I make it work in the java file ?
In your activity, add an on click listener to your button that zooms in the webview:
findViewById(R.id.zoom_in_btn).setOnClickListener(
new View.OnClickListener() {
#Override
public void onClick(View v)
{
webviewer.zoomIn();
}
});
I am using this lib for my project.
https://github.com/adamrocker/simple-side-drawer
I would like to change current layout of SideDrawer to another layout.
is it possible ?
there are many applications that use this approach. like :
https://play.google.com/store/apps/details?id=com.zalora.android&hl=en
is there an example ?
I checked the code provided in the github repository you've referenced. I found this :
mNav = new SimpleSideDrawer(this);
mNav.setLeftBehindContentView(R.layout.activity_behind_left_simple);
findViewById(R.id.leftBtn).setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
mNav.toggleLeftDrawer();
}
});
mNav.setRightBehindContentView(R.layout.activity_behind_right_simple);
findViewById(R.id.rightBtn).setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
mNav.toggleRightDrawer();
}
});
So maybe you cuold have a listner on your button in the leftBehindContent which will perform action like :
mNav.setRightBehindContentView(R.layout.new_layout)
new_layout.xml must be present in your android layout folder ;) !
Getting the following error onclick of minus remove button:
Could not find method android.view.View.getParentForAccessibility,
referenced from method com.wassap.main.UserFragment$12.onClick
Relevant code:
/////////////////////// minus remove button click
imgRemove.setOnClickListener(new OnClickListener()
{
#SuppressLint("NewApi")
public void onClick(View vv)
{
View parent = (View) vv.getParentForAccessibility();
}
});
getParentForAccessibility is available since Android 16. So you need a device with at least that api level to run it
i'm using setColorFilter to color some button... the code is this:
final Button falso = (Button) findViewById(R.id.falso);
final Button vero = (Button) findViewById(R.id.vero);
vero.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
vero.getBackground().setColorFilter(new LightingColorFilter(0x00000000, 0x00FF0FF));
falso.getBackground().clearColorFilter();
esame.set("V");
}
});
falso.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
falso.getBackground().setColorFilter(new LightingColorFilter(0x00000000, 0x00FF0FF));
vero.getBackground().clearColorFilter();
esame.set("F");
}
});
when i click the button "vero" i want reset the colour of "falso" and viceversa.
i tried this code on android ics and all work good, but when i tried it on android 2.3 i have a bad surprise.
when i click the button the colour don't reset and i don't understand why.
i find the solution:
use button.invalidate();
after i clear background
Setting the ColorFilter to 0 will do thee job by clearing the filter.
vero.setInt(vero.getBackground(), "setColorFilter", 0);