Set tab active when an Activity loads for the first time (Android SlidingTabLayout) - pagerslidingtabstrip

Using SlidngTabLayout
, i'm not able to set the first tab as active when my activity loads for the first time. Once i click on it, it works fine. However, i need my first tab to be automatically selected when the activity starts the first time

Inside SlidingTabLayout.java i modified the InternalViewPagerListener this way,
So basically, inside onPageScrolled method, i did this.
if (position == 0)
selectedTitle.setSelected(true);
else
mTabStrip.getChildAt(0).setSelected(false);
Done! Happy coding :)

Related

DOM usage in QTP

During script execution a pop up won't go away, and it happens only through QTP(v12.02).
I am trying DOM to bypass the problem, the pop up event was on selection of a drop down value, so I used some code to find the correct index and use DOM to select the value
Browser().Page().WebList().Object.selectedIndex = itmindx
With this the pop up issue got resolved, but now to complete the process,I need to click the Save button which is disabled as the page didn't refreshed when the value was selected ( tried refreshing through QTP, tab out etc--didn't worked as it loads the previous value).So I used the fire event method
Browser().Page().WebList().Fireevent "onchange"
with this I ran in to the same issue of multiple pop ups. Used the following
Browser().Page().WebList().Object.onchange()
but then QTP won't executes the next line unless I hit enter externally on the pop up(multiple pop up is resovled but now QTP is stuck. I don't want to use RS.... Any solutions?
To enable the button
Browser().Page().WebButton().Object.disabled = false
Or
To hit enter for the popup
CreateObject("WScript.Shell").SendKeys("{ENTER}")
[ http://ss64.com/vb/sendkeys.html ]
Go for hitting the Enter button using SendKeys. It is not a good idea accessing DOM and change the state ourselves. There is a chance that you might miss potential defects!

ionic tabscontroller make not-first active on startup

When you start an ionic application with a tabbar on the bottom, it always starts the App with the first Tab active.
But I have 3 tabs, and I want the Tab in the middle to be the active Tab that starts when I open the App.
Can't find in the docs how to do this. Someone?
There is $ionicTabsDelegate for your needs. You can inject it into any controller, or your app's run block. Then you do it similar to the example:
function MyCtrl($scope, $ionicTabsDelegate) {
//use 1 to select the second tab (starts with 0)
$ionicTabsDelegate.select(1);
}
if you want to have it when your app starts, put in in your run block

how to call previous activity in android?

I have five activity in my app,
Act1->Act2->Act3->Act4->Act5,
All activity goes in single direction as I have stated above,
Now I have to call again Act2 after successful completion of my Act5's task, so its working good and showing me the Act2 (I have Used startActivity(callIntent) in Act5 for showing me Act2 again),
After this when I click on Back button in Act2, I have Act1 (I have Used startActivity(callIntent) in Act2 for showing me Act1 again) its what I want .....
But the problem is that when I click Act1's back button it is going to put me on Act2. But I want to exit from there, because Act1 is the first initial activity.
How Can I set focus to my hidden activity , instead of creating Intent and call startActivity.
Any idea? Please help.
After long research I got pretty much understanding of "back stack" for all the activities in an app.
Each time I moved to another activity and also for opening previous activity I have used Intent.startActivity() with flag FLAG_ACTIVITY_NEW_TASK, So every time I have new activity added in the "back-stack".
I have tried intent flag as FLAG_ACTIVITY_CLEAR_TOP while calling previous activity from "back-stack" using Intent.startActivity() and I got the solution of calling back the previous activity and clears all stack top activity above the calling one activity. So now back button does working nice as I needed.
Let see My problem of calling previous activity ,
A = activity; A1->A2->A3->A4->A5->B2 , now if you click on back button you will have A1 activity , and after clicking on A1's back button you have again B2 activity which was called after A5 and so on.
After using the FLAG_ACTIVITY_CLEAR_TOP in A5 activity and called again A2 (Not creating new activity but calling precious one) I have following situation.
A = activity; A1->A2->A3->A4->A5
calling previous A2 activity, and I have following scenario.
A1->A2 only.
Thanks.
Instead of following code (with flag Intent.FLAG_ACTIVITY_NEW_TASK):
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
callIntent.setClass(CurrentActivity.this,PreviousActivity.class);
startActivity(callIntent);
Try using following one with Intent.FLAG_ACTIVITY_CLEAR_TOP
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
callIntent.setClass(CurrentActivity.this,PreviousActivity.class);
startActivity(callIntent);

iOS: selecting option returns null first time, not second time

I have an iOS application where you select an option before you log in. The way it works is that you click on the button that says "Select", then it takes you to a UITableViewController which shows you the options, you select the option, and it takes you back to the previous menu with the text replaced with your selection (and a hidden ID saved, too).
During the update of the information (which takes place in tableView:didSelectRowAtIndexPath:) I call NSLog on the object. The first time I call it, it returns null (BUT for some reason the text still changes!) and the second time I call it, it works! Why doesn't it work the first time????
Thanks
Do you put the NSLog line before the previous view push back code ?
The variable was named incorrectly. I don't know why XCode didn't just tell me this instead of giving me an EXC_BAD_ACCESS, but that's what happened.

How to unload js script when going to next tab in jquery?

I have a site with five tabs using jquery-ui. Each loads an individual jQuery script. Now when I have loaded the second tab and go to the third tab the js out of the second tab still remains active and disturbs my actions in the third tab space.
Can someone explain me why the js out of the second tab still stays active when changing to the third tab and how I can avoid such behaviour?
Once you have loaded a script onto the page, it remains active until the page refreshes.
I don't know about unloading, but you can certainly disable the actions of a certain script depending on what it is. Could you post an example of the script causing the issues?
EDIT:
For example, if you have a script that is dependent on the tab you are in, you can condition the actions in the script with the tabs being at a certain index. A demo syntax:
//will only execute action if you are in current tab
if(tabs_ui_index == 0){
//do something
}
to get that variable (tabs_ui_index) you can do something like this:
$('#mytabs').bind('tabsselect', function(event, ui) {
tabs_ui_index = ui.index;
});
This code binds a "tabsselect" event to the element that is tabbed and sets the variable to the currently indexed tab every time a user changes a tab.
Also, you can unbind events, if you loaded a script that set a click event for a button that no longer exists, or that you are using for a different purpose now:
$("#mybutton").unbind("click");
I hope this helps. Let me know if you have any other questions.