Android iterative development in succession encountered a variety of problems, we should be good at summing up, classification. Now take a look at the summary of issues that have been encountered in the past few months.
1, Android fragment Onactivityresult method returned no data
Return the data, possibly intent data has the information or is an int requestcode This parameter return code has the error.
Workaround:
In the activity need to add Super.onactivityresult (Requestcode, ResultCode, data);
@Overrideprotected void Onactivityresult (int requestcode, int resultcode, Intent data) {Super.onactivityresult ( Requestcode, ResultCode, data), if (data = = null) return;//page return value if (= = Requestcode) {}}
booting in fragment is like this.
Getactivity (). Startactivityforresult (newintent,100);
Need to precede with getactivity ().
2. Scroll top or bottom of Android ListView
A, public void setselection (int position)
The item at the position position is pinned (that is, the item at the position position to the top of the ListView), but there is no sliding effect from the original position to the top.
Listview.setselection (0); Scroll to the top.
b, public void setselectionfromtop (int position, int y)
Similar to SetSelection. SetSelection (position) is setselectionfromtop (position,0)
Select the item specified by position and place the selection at the top y-pixel distance from the listview
Parameter position the index of the item to be selected (starting at 0) y distance from the top of the ListView (including The Gap)
c, public void smoothscrolltopositionfromtop (int position, int offset)
Scrolls smoothly to the specified adapter location. The view at the specified position is scrolled to the position of offset pixels relative to the top edge.
If this is not possible (for example, the offset will make the top and end entries go beyond the edge of the list), it will scroll to the nearest possible position.
Parameters
Position scroll to the point where offset scrolling ends, specify the number of pixels that the position entry is from the top of the view
When offset=0, you can put the item of the position position on top, and with the sliding effect, you will swipe from the original position to the topmost position.
D, the scroll top or bottom of the ListView
The ListView scrolls to the bottom listview.setselection (ListView. GetCount ()-1);
The ListView scrolls to the top of the ListView. SetSelection (0);
or Listview.setselectionafterheaderview ();
or list.smoothscrolltoposition (0);
These need to be called after the Setadapter method and the Notifydatasetchanged method.
3, 64-bit encoding generation
<span style= "FONT-SIZE:14PX;" >strbasic = base64.encodetostring (Strbasic.getbytes (), Base64.default);</span>
4. Eclipse removes all debug breakpointsdebugging when found to add too many breakpoints, want to remove all breakpoints, just remembered has not used this function, put the dog search, quickly found, record.
Method One:
In the work interface, click the Window menu bar, select Preperences, and under the key node in the General tab,
Locate the Accelerator entry field, enter remove in the type filter text, remove all breakpoints appears in the following self-prompt, and the Undo function key We're looking for is it.
Then change it to your desired hotkey according to your needs.
Method Two:
In the Debug mode window, click the Run menu bar, in the Dropdown tab, at the bottom we can see the Remove all Breakpoints option,
As soon as I click on it, all breakpoints in our currently debugged project will be revoked.
5. Android Actionbar Custom title bar
Layoutparams mlayoutparams = new Layoutparams (layoutparams.wrap_content, layoutparams.wrap_content,gravity.left| gravity.center_vertical); Getactionbar (). Setdisplayoptions (Actionbar.display_show_custom); View CustomView = getlayoutinflater (). Inflate (r.layout.custom_title_setting, NULL); TextView Titletextview = (TextView) Customview.findviewbyid (r.id.textviewtitle); Titletextview.settext (StrTitle); Getactionbar (). Setcustomview (Customview,mlayoutparams); Getactionbar (). Setdisplayshowcustomenabled (True);
6, Android Actionbar logo display problem in the upper left corner
By default, your app's icon is displayed on the action bar in the <application> or <activity> tab via the Android:icon property, but we can also use Android: Logo properties to specify a different icon to display. If you do not want some activity to display the logo, in the <activity> tag registration time Android:logo attribute icon Reference transparent a small picture can.
Remove the app icon to display Getactionbar (). setdisplayshowhomeenabled (false); Actionbarsherlock Frame title bar shows return icon //Add Back button Getactionbar (). Setdisplayhomeasupenabled (True);
If the Viewpager+fragment slide tab is used. You will find the title bar with tab Options Bar who is at the top of the question.
is controlled by the following line of code. What do you want to achieve, according to my point of view logo problem.
Android daily iteration and maintenance Summary II