Horizontal progressbar with custom color

Categories: ANDROID like

activity_main.xml <progressbar android:id=”@+id/progressBar” style=”?android:progressBarStyleHorizontal” android:layout_width=”match_parent” android:layout_height=”1dp” android:layout_margin=”0dp” android:max=”100″ android:padding=”0dp” tools:progress=”40″ android:progressDrawable=”@drawable/progress_drawable” app:layout_collapseMode=”pin”/> MainActivity.java ProgressBar mProgressBar = (ProgressBar) findViewById(R.id.progressBar); //somewhere when scrollin mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() { @Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) { super.onScrolled(recyclerView, dx, dy); int lastVisiblePosition = mLayoutManager.findLastVisibleItemPosition(); int allItem = mLayoutManager.getItemCount(); if (allItem > 0) { double v = ((double) lastVisiblePosition […]

GCM notification with custom sound – shorter version (part)

Categories: ANDROID like

Here is a short example how to create notification with default stuff but different sound: NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_launcher) .setContentTitle("title") .setStyle(new NotificationCompat.BigTextStyle() .bigText("message")) .setContentText("message") .setAutoCancel(true) .setSound(soundUri) .setDefaults(NotificationCompat.DEFAULT_ALL ^ NotificationCompat.DEFAULT_SOUND); The most important part is here: .setDefaults(NotificationCompat.DEFAULT_ALL ^ NotificationCompat.DEFAULT_SOUND) Symbol ^ says “except”, so the last part would say “give me default notification except […]

Custom checkable list item with checkbox (layout+code)

Categories: ANDROID like

Here is simple example how to create simple checkable list item with checbox. This a code for widget: public class CheckableTextView extends LinearLayout { private TextView checkLabel; private CheckBox checkBox; public CheckableTextView(Context context) { super(context); } public CheckableTextView(Context context, AttributeSet attrs) { super(context, attrs); init(); } public CheckableTextView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, […]