Error On Symbol R in Android(Common Error)

Clean and rebuild your project. Select Build > Clean Project from the Android Studio toolbar, wait a few moments, and then build your project by selecting Build > Rebuild Project.

OR

Select File > Invalidate Caches / Restart > Invalidate and Restart from Android Studio toolbar.

Multiple Fragment Attachment (Nullpointer Exception onchange Fragment multiple Click on tab change)

In this type of problem is common in Fragment replacement in Android.


	Context context;								 
	@Override
        public void onAttach(Context context) {
        super.onAttach(context);
        this.context=context;
    }

Design not set according Devices height and width in Android

Using Display Metrics you can set android design(Layoutparams) according devices.

	
									   
DisplayMetrics metrics;
int deviceHeight, deviceWidth;
	
metrics = new DisplayMetrics();
WindowManager wm = (WindowManager) getActivity().getSystemService(Context.WINDOW_SERVICE);
wm.getDefaultDisplay().getMetrics(metrics);
deviceHeight = metrics.heightPixels;
deviceWidth = metrics.widthPixels;
		
									   

Image Loading & rotate Problem in Android.

Some time image view show black screen and image rotate. Glide library easy to load image in android.

compile 'com.github.bumptech.glide:glide:3.7.0'

try {
        Glide.with(context)
		.load(new File(path))
		.placeholder(R.drawable.broken_thumb)
		.error(R.drawable.broken_thumb)
		.centerCrop()
		.into(imageview);

            } catch (Exception e) {
                e.printStackTrace();
            }
									   
									   

Android Developement

  • Android

  • Android Studio

  • Android development