android-actionbar

Android fragments in actionBar tabs

允我心安 提交于 2019-12-13 07:44:23
问题 So I have 3 actionBar tabs running 3 different fragment classes. In Tab1 of the actionBar I have a simple form that a user fills in and the data is then saved in an SQLite database, this form and the tasks carried out on it work fine as a project by itself but when I tried to integrate it as a fragment (FragmentTab1) then the app crashes when I click the save button. Any ideas as to why it may be crashing? I think I may have to implement an onClickListener maybe, not sure though! I am aware

How to make a Custom View(EditText) on the actionbar automatically selected?

佐手、 提交于 2019-12-13 06:47:48
问题 Currently I am making an app that has an EditText on the action bar. I found out how to put a custom view on an actionbar from the following link: How to set a custom view in actionbar in android?. I used the getSupportActionBar to load an EditText onto the action bar. getSupportActionBar.setCustomView(R.layout.actionbar_view); It loads an xml file called actionbar_view.xml. The code for that xml file follows below. <?xml version="1.0" encoding="utf-8"?> <EditText xmlns:android="http:/

Get rid of this line separator between my action-bar and pagertabview:

隐身守侯 提交于 2019-12-13 06:41:04
问题 I'm trying to get rid of this line separator between my action-bar and pagertabview: How did Google achieve this? 回答1: That isn't really a line separator, it is a shadow indicating that the Action Bar is at a higher elevation than the tab bar. Assuming you are using AppCompat, you can use ViewCompat.setElevation() to set the elevation on your tabs for devices that support it (those running API 21+). Your code might look something like this: View tabs = findViewById(R.id.the_tabs_id)

Actionbar title font not changing in android

允我心安 提交于 2019-12-13 05:57:57
问题 I want to change a custom font to my action bar title, have gone through couple of accepted answers,but no luck,I have tried as below,But my custom font is not applied to my actionbar title,Please help me to get rid of this,my code is as below: java Typeface font = Typeface.createFromAsset(getActivity().getAssets(), "neuropolx.ttf"); SpannableString s = new SpannableString( " KOLAY RANDEVU"); s.setSpan(new CustomTypefaceSpan("", font), 0, 4, Spanned.SPAN_EXCLUSIVE_INCLUSIVE); getActivity()

Show Action Bar when user does not interact for some time in Android

女生的网名这么多〃 提交于 2019-12-13 05:34:56
问题 Hi in my android app I would like to hide the action bar on user interaction and show it again when the user has stopped interacting for some time. Now I already have the code for hiding the action bar: mViewPager.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { // TODO Auto-generated method stub getActionBar().hide(); return false; } }); I simply added an onTouchListener to my main view But I do not know how to implement the

Search item on action bar android

懵懂的女人 提交于 2019-12-13 05:26:22
问题 First of all see what I have done yet. This is my menu.xml file. <?xml version="1.0" encoding="utf-8"?> <item android:id="@+id/friend" android:title="friend_list" android:icon="@drawable/friends" android:showAsAction="ifRoom"/> <item android:id="@+id/search" android:title="search" android:icon="@drawable/search" android:showAsAction="always|collapseActionView" android:actionViewClass="android.widget.SearchView" /> <item android:id="@+id/profile" android:title="@string/profile" /> <item

Switch (Button) throws NullPointerException

筅森魡賤 提交于 2019-12-13 05:24:40
问题 I know this question already exists, but I tried serveral solutions and none worked for me. In my case, I need a Switch Button in the ActionBar. I tried to manually add a minSdk Verision I tried to use the id of the item in the defined xml Edit: The exception-point in the code is marked with a comments. It's in the mainactivity. :) Here is some of my code: mainactivity: @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout

Android - NullPointerException on SearchView in Fragment

一个人想着一个人 提交于 2019-12-13 04:59:36
问题 I am always getting searchView null at below line in my fragment class: SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem); here is my fragment class, Please find onCreateOptionsMenu method at bottom: public class FriendsListActivity extends Fragment implements EventListener { ArrayList<Users> friendList = new ArrayList<Users>(); ArrayList<Users> blockedList = new ArrayList<Users>(); ArrayList<Users> famliyList = new ArrayList<Users>(); ArrayList<Users>

How to change the color of the android actionbar without using any image resource?

感情迁移 提交于 2019-12-13 04:51:58
问题 I want to change the color of my actionbar but I'm no good at making image resources so I want to know if there is anyway it is possible to do that without images. like setting a color to some property or something? I surfed a lot but there are too many confusing answers and I can't figure out which one to use. I am developing for sdk above 8 so I'm using support libraries. Please help. 回答1: You could have easily found out the answer here. Or you can click here to create image resources very

custom action bar relative layout children not placed correctly

懵懂的女人 提交于 2019-12-13 04:34:10
问题 I am using the following RelativeLayout to create a custom action bar. The problem is that height_indicator is not showing to the right of animals_view_title . Instead, they appear superimposed: both at the center. Now on the Graphical Layout it looks correct. But when I run it on my S4 it fails. <RelativeLayout android:id="@+id/my_rel_view" android:layout_width="match_parent" android:layout_height="match_parent" android:theme="@style/CustomTheme" android:visibility="visible" > <TextView