I'm trying to make plusone button works inside my android app.
I did this:
m_plusClient = new PlusClient(this, this, this);
Then:
m_plusOneButton = (PlusOneButton) m_view.findViewById(R.id.plus_one_button);
m_plusOneButton.initialize(((SinglePlace)getActivity()).m_plusClient, url, 0);
Button is there, but if I click it, it shows an indefinite progress bar and does nothing. No callbacks are called on plus client...
You need to follow these steps first:
https://developers.google.com/+/mobile/android/getting-started
before you jump to +1 button section.
Related
I'm developing an Android TV application which is using Leanback library. There is a login form with email, password and a login button. I'd like to enable the login button only when the email and password are valid.
Here is my code:
mLoginButtonAction = new GuidedAction.Builder(this.getActivity())
.id(id)
.title(title)
.description(desc)
.build();
actions.add(action);
I disable it at first:
mLoginButtonAction.setEnabled(false);
And then enable it when it's valid:
mLoginButtonAction.setEnabled(valid);
The button is then enabled and I'm able to click it. But the color of the button is still the same color as in disable mode. Any idea? Thanks.
Modification to actions do not trigger notifications to the GuidedStepFragment and must be done so manually.
To notify an action change you first need the items index.
int idx = findActionPositionById(actionId);
Get and modify your action
GuidedAction someAction = getActions().get(idx);
someAction.setEnabled(valid);
Next notify the fragment of the update
notifyActionChanged(idx);
I'm working on a firefox for android addon, and there is a function that i need to be fired every time a new page (tab) is loaded: a new tab is opened or the address of the current tab changes. I tried to use listener ("load"/"tabSelect") but the first one didn't work and the second doesn't detect the address bar changes:
window.BrowserApp.deck.addEventListener("load", onPageLoad, true);
Should I add more than one listener? and I found this, but it doesn't work for firefox for android. Thank you for your help.
I don't know why "load" is not working for you. I do know that "load" is sometimes not called, when loading a page from back/forward session history for example. To work around that, you could try using the "pageshow" event. That will be called for any page-change.
For more info see: https://developer.mozilla.org/en-US/docs/Code_snippets/Mobile
I'm creating an android app where user loads some data from an online server when he hits a button
I need to add the following :
when user hits the button a pop-up screen shows on top of current screen & shows something like
"loading" "spinning loader" or anything like this
any thoughts ?
Have a look at this Android Developer page at the section "Creating a ProgressDialog". Android offers such a dialog out of the box.
You can try a function like showProgressDialog(Activity activity)with this context:
if ((mySpinnerDialog== null) || (!mySpinnerDialog.isShowing())) {
mySpinnerDialog= new Dialog(activity);
mySpinnerDialog.getWindow().getCurrentFocus();
mySpinnerDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
mySpinnerDialog.setContentView(R.layout.some_layout);
mySpinnerDialog.setCancelable(false);
mySpinnerDialog.setOwnerActivity(activity);
mySpinnerDialog.show();
} else {
mySpinnerDialog.setOwnerActivity(activity);
}
and dismiss this with mySpinnerDialog.dismiss();. Handle Illegalargumentexception on dismiss()
I want to obtain a similar tab effect with the button bar of twitter app.
I wish to click on a button and change the view down. I can switch activity but I think It's wrong, or not?
The top bar have to be fix like a frame. Like this:
Ok now I post a part of my idea (i found something similar here: http://www.talkandroid.com/android-forums/android-development-answers-tutorials-code-snippets/1515-how-i-open-image-imagebutton.html)
code:
newsButton = (ImageButton) findViewById(R.id.news);
newsButton.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
// on click go to the news view (no activity yet)
setContentView(R.layout.news);
}
});
Like in the Google IO App?
If so, the Source Code is freely available here.
Okay, a little tour on how Google does it:
The activity_home.xml-layout
includes (Line 21) the
actionbar.xml-layout (This is done
in every Layout so the Actionbar
must not always be duplicated).
The actionbar.xml-Layout
creates a LinearLayout for
the UI-Elements.
Then, for example the
HomeActivity-Activity sets
the content view to the
activity_home.xml-layout, receives
an ActivityHelper-class and calls
its setupActionBar()-method.
The mantioned ActivityHelper-class
is in the hg/ android/ src/ com/
google/ android/ apps/ iosched/
util/-package and has the
setupActionBar()-method which
creates the Action bar.
This might be easier then it looks. Read your way through the Source Code and try it yourself.
I think these controls are Radio Button/ Radio Group with customization.
I have a unit test that opens up a custom dialog and enters some text. This works, but I am unable to accept the dialog or get hold of the ok button. Please can anyone tell me how to automate the dialog acceptance using junit.
ActivityMonitor activityMonitor = instrumentation.addMonitor(
EditItem.class.getName(), null, false);
instrumentation.sendKeyDownUpSync(KeyEvent.KEYCODE_MENU);
instrumentation.invokeContextMenuAction(gridList, R.id.add, 0);
Activity activity = instrumentation.waitForMonitorWithTimeout(
activityMonitor, 10);
assertNotNull("Make sure the edit item activity was called", activity);
assertEquals("Make sure the edit item activity was called",
EditItem.class, activity.getClass());
final TextView nameView = (TextView) activity.findViewById(R.id.name);
// this opens the dialog
TouchUtils.clickView(this, nameView);
// this adds some text
for (int i = 0; i < 3; i++)
{
instrumentation.sendKeyDownUpSync(KeyEvent.KEYCODE_X);
}
// here I would like to accept the ok button on the dialog
OK I seem to have worked round this with a combination of key presses
instrumentation.sendKeyDownUpSync(KeyEvent.KEYCODE_DPAD_DOWN);
instrumentation.sendKeyDownUpSync(KeyEvent.KEYCODE_DPAD_CENTER);
The problem is now I can't tell when the dialog has finished being dismissed and returned to the parent Activity to continue the test with a
instrumentation.sendKeyDownUpSync(KeyEvent.KEYCODE_BACK);
Go a work around for this too now:
instrumentation.waitForIdleSync();
instrumentation.sendKeyDownUpSync(KeyEvent.KEYCODE_BACK);
Seems a bit clunky, is this how you are supposed to use these tools?
I'm having the same problem. What it looks like is that you will have to create a custom dialog. This will allow you to retrieve the buttons you added using the findViewById(). Here is a link that I found that might get you on the right path.
http://www.mkyong.com/android/android-custom-dialog-example/