Posts

Showing posts from November, 2013

Simple drawing example in Android

Image
This post is a simple drawing example using Canvas, BitMap, Paint and Path classes from Android.
Code:

MainActivity.java

import java.util.ArrayList; import android.app.Activity; import android.content.Context; import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.graphics.Path; import android.os.Bundle; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup.LayoutParams; import android.widget.LinearLayout; public class DrwaingActivity extends Activity { View mView; private Paint mPaint; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); LinearLayout layout = (LinearLayout) findViewById(R.id.myDrawing); mView = new DrawingView(this); layout.addView(mView, new LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT))…

Simple Sliding Menu Example in Android

Image
Consider using simple NavigationView instead of this old sliding menu , which based on Material design and much simpler and very flexible than this Navigation drawer.

This post will help you to create a simple sliding menu in Android.
Here sliding menu is a listview which is in INVISIBLE state. It will comes to VISIBLE state once you click the menu button. And it will go to INVISIBLE state again once you pick the item from listview. To change the state we are using animation, that is why it looks like sliding.

Complete code:

MainActivity.java

package com.android.slidingmenuexample; import android.os.Bundle; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentTransaction; import android.view.Menu; import android.view.View; import android.view.View.OnClickListener; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.Button; …