Android icon error -
i copied code tutorial site because trying learn it. getting error at
package com.android.test; import android.r; import android.app.activity; import android.graphics.bitmap; import android.graphics.bitmapfactory; import android.graphics.matrix; import android.graphics.drawable.bitmapdrawable; import android.os.bundle; import android.view.view; import android.widget.adapterview; import android.widget.arrayadapter; import android.widget.imageview; import android.widget.seekbar; import android.widget.spinner; import android.view.viewgroup.layoutparams; import android.widget.linearlayout; import android.widget.imageview.scaletype; public class rotate extends activity { @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); linearlayout linearlayout = new linearlayout(this); bitmap bitmap = bitmapfactory.decoderesource(getresources(), r.drawable.icon); on last line, error ".icon" written. says, "icon cannot resolved or not field."
int width = bitmap.getwidth(); int height = bitmap.getheight();
matrix matrix = new matrix(); matrix.postrotate(90); bitmap rotatedbitmap = bitmap.createbitmap(bitmap, 0, 0,width, height, matrix, true); bitmapdrawable bmd = new bitmapdrawable(rotatedbitmap);
imageview imageview = new imageview(this); imageview.setimagedrawable(bmd); imageview.setscaletype(scaletype.center); linearlayout.addview(imageview, new linearlayout.layoutparams( layoutparams.fill_parent, layoutparams.fill_parent)); setcontentview(linearlayout); } }
in import statements, have
import android.r; that means it'll in android.r.drawable.icon, rathern r.drawable.icon. android.r contains ids assets sdk. access own assets, need remove using statement, or manually write com.your.package.name.r.drawable.icon
Comments
Post a Comment