android – Shaped drawable with selectableItemBackground as background-ThrowExceptions

Exception or error: I have couple buttons that I need an oval shaped border. So i have this in a capsule_border.xml <?xml version=”1.0″ encoding=”UTF-8″?> <shape xmlns:android=”http://schemas.android.com/apk/res/android”> <corners android:radius=”9999dp”/> <stroke android:width=”1px” android:color=”@color/border_gray” /> </shape> And I would use android:background=”@drawable/capsule_border.xml where I need it. Now, I would like to have a button to have this oval shaped …

android – onOptionsItemSelected not getting called when using custom action view-ThrowExceptions

Exception or error: I set an custom view for one of my actionbar MenuBar like this @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.loop_thread, menu); ImageView iv = (ImageView)(getLayoutInflater().inflate(R.layout.image_container, null)); menu.findItem(R.id.action_filter).setActionView(iv); … but when I tap that menu item in my app, onOptionsItemSelected() does not get called. (I have verified this via setting a breakpoint at …

android – Null FragmentTransaction being passed to TabListener.onTabSelected()-ThrowExceptions

Exception or error: I’m adding navigation tabs to an action bar using the sample code provided here: http://developer.android.com/guide/topics/ui/actionbar.html I’m using ActionBarSherlock. My TabListener is copied directly from the docs. public static class TabListener<T extends Fragment> implements ActionBar.TabListener { private Fragment mFragment; private final Activity mActivity; private final String mTag; private final Class<T> mClass; /** Constructor …

android – How to select a video from the gallery and get it's real path?-ThrowExceptions

Exception or error: I can open the gallery with this code, Intent intent = new Intent(Intent.ACTION_PICK); intent.setType(“video/*”); intent.setAction(Intent.ACTION_GET_CONTENT); startActivityForResult(Intent.createChooser(intent, “Select Video”), PICK_VIDEO_REQUEST ); It works well on a Samsung Galaxy S5. But in some phones, images are displayed along with videos. What changes do I need to do to the code to open the gallery …

"Press and hold" button on Android needs to change states (custom XML selector) using onTouchListener-ThrowExceptions

Exception or error: I’ve got a button graphic which needs to have “press and hold” functionality, so instead of using onClickListener, I’m using onTouchListener so that the app can react to MotionEvent.ACTION_DOWN, and MotionEvent.ACTION_UP Depending on how quickly those two events are triggered, I can run a “pressAndHoldHandler” in the time between the two. Anyway, …

Implementing a File Picker in Android and copying the selected file to another location-ThrowExceptions

Exception or error: I’m trying to implement a File Picker in my Android project. What I’ve been able to do so far is : Intent chooseFile; Intent intent; chooseFile = new Intent(Intent.ACTION_GET_CONTENT); chooseFile.setType(“*/*”); intent = Intent.createChooser(chooseFile, “Choose a file”); startActivityForResult(intent, PICKFILE_RESULT_CODE); And then in my onActivityResult() switch(requestCode){ case PICKFILE_RESULT_CODE: if(resultCode==-1){ Uri uri = data.getData(); String …

How to Get Selected Text and Value Android ListPreference-ThrowExceptions

Exception or error: The XML file of my ListPreference <ListPreference android:key=”lpBirim” android:title=”Birim” android:summary=”” android:defaultValue=”0″ android:persistent=”false”/> How to get the selected text and the selected value? How to solve: in your PreferenceActivity do something like: ListPreference listPreference = (ListPreference) findPreference(“lpBirim”); CharSequence currText = listPreference.getEntry(); String currValue = listPreference.getValue(); ### You can use this snippet to get …