How to disable items in a List View?
Make your own subclass of ArrayAdapter that has AreAllItemsEnabled() return false, and define isEnabled(int position) to return true/false for a given item in your data set.
Make your own subclass of ArrayAdapter that has AreAllItemsEnabled() return false, and define isEnabled(int position) to return true/false for a given item in your data set.
Unfortunately, you can’t style it. The styles and styling attributes for NumberPicker are not present in the public API, therefore you can’t set them and change the default look. You can only select between light and dark theme. As a solution I would suggest to use android-numberpicker library instead. The library is basically a port … Read more
here’s what I use: public static void logHeap() { Double allocated = new Double(Debug.getNativeHeapAllocatedSize())/new Double((1048576)); Double available = new Double(Debug.getNativeHeapSize())/1048576.0; Double free = new Double(Debug.getNativeHeapFreeSize())/1048576.0; DecimalFormat df = new DecimalFormat(); df.setMaximumFractionDigits(2); df.setMinimumFractionDigits(2); Log.d(“tag”, “debug. =================================”); Log.d(“tag”, “debug.heap native: allocated ” + df.format(allocated) + “MB of ” + df.format(available) + “MB (” + df.format(free) + “MB … Read more
I have found snippets somewhere on internet few months ago, I have made changes and recently uploaded the working demo on my github account, You can have a look at this Note: It will disable “hardware” home button. I hope it will be helpfull !! Screenshots: It provides lockscreen in API 8 or above. Initial … Read more
int id = getResources().getIdentifier(imageName, type, package); This will get you the ID of the resource you are looking for. With it, you can then access the resource from the R class. Using only the name parameter: You can also include all the 3 info in the “name” parameter using the following format: “package:type/image_name”, something like: … Read more
You can do something like this to code for both versions: /** * Sets the Action Bar for new Android versions. */ @TargetApi(Build.VERSION_CODES.HONEYCOMB) private void actionBarSetup() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { ActionBar ab = getActionBar(); ab.setTitle(“My Title”); ab.setSubtitle(“sub-title”); } } Then call actionBarSetup() in onCreate(). The if runs the code only on new Android … Read more
Put both DatePicker and TimePicker in a layout XML. date_time_picker.xml: <?xml version=”1.0″ encoding=”utf-8″?> <LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:orientation=”vertical” android:layout_width=”match_parent” android:padding=”8dp” android:layout_height=”match_parent”> <DatePicker android:id=”@+id/date_picker” android:layout_width=”match_parent” android:calendarViewShown=”true” android:spinnersShown=”false” android:layout_weight=”4″ android:layout_height=”0dp” /> <TimePicker android:id=”@+id/time_picker” android:layout_weight=”4″ android:layout_width=”match_parent” android:layout_height=”0dp” /> <Button android:id=”@+id/date_time_set” android:layout_weight=”1″ android:layout_width=”match_parent” android:text=”Set” android:layout_height=”0dp” /> </LinearLayout> The code: final View dialogView = View.inflate(activity, R.layout.date_time_picker, null); final AlertDialog alertDialog = new … Read more
I pretty much left my custom view intact, and implemented an ImageView for my widget, then rendered the view using the getDrawingCache() MyView myView = new MyView(context); myView.measure(150,150); myView.layout(0,0,150,150); myView.setDrawingCacheEnabled(true); Bitmap bitmap=myView.getDrawingCache(); remoteViews.setImageViewBitmap(R.id.dial, bitmap);
Now this works fine for soft/hard keyboard for all delete/edit ops. tx 4 ur help.. package com.and; import android.app.Activity; import android.app.AlertDialog; import android.inputmethodservice.KeyboardView; import android.os.Bundle; import android.telephony.PhoneNumberFormattingTextWatcher; import android.text.Editable; import android.text.Selection; import android.text.Spannable; import android.text.TextWatcher; import android.text.format.Formatter; import android.text.method.NumberKeyListener; import android.view.KeyEvent; import android.view.View; import android.view.View.OnKeyListener; import android.widget.EditText; import android.widget.Toast; public class ccformat extends Activity { … Read more
Since you don’t specify what you can’t grasp from the API it’s hard to answer your questions (short answer: rewrite your question to a specific questions rather than a general one). A typical Spannable-example is something like this to turn selected text in an EditText into Italic: Spannable str = mBodyText.getText(); if(mBodyText.getSelectionEnd() > mBodyText.getSelectionStart()) str.setSpan(new … Read more