안드로이드 개발 질문/답변
(글 수 45,052)
맞게 한거 같은데 에러가 자꾸나네요
머를 잘못 한걸까요??ㅜㅜ
아시는분 아이유같은 여친생기실꺼에요~!!
에러는 이렇습니다
04-06 14:15:18.169: ERROR/AndroidRuntime(22037): java.lang.RuntimeException: Unable to start activity ComponentInfo{net.tredio.elecgal/net.tredio.elecgal.editactivity.CropActivity}: android.view.InflateException: Binary XML file line #15: Error inflating class net.tredio.elecgal.editactivity.CropImageView
CropImageView.java
public class CropImageView extends ImageView {
private DragAndDropEvent event = new DragAndDropEvent();
private OnDragAndDropListener listener;
public CropImageView(Context context) {
super(context);
}
@Override
public boolean onTouchEvent(MotionEvent event){
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
this.event.start.setMotionEvent(event);
break;
case MotionEvent.ACTION_UP:
this.event.end.setMotionEvent(event);
if (listener != null) {
listener.onDragAndDropEvent(this.event);
}
break;
}
return true;
}
}
CropActivity.java
public class CropActivity extends Activity{
private static String log = "CropActivity";
Image image ;
CropImageView frame ;
Bitmap modbitmap ;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.crop);
frame = new CropImageView(CropActivity.this);
frame = (CropImageView) findViewById(R.id.cropview);
Intent intent = getIntent();
String temppath = intent.getStringExtra("temppath");
Bitmap tmp = BitmapFactory.decodeFile(temppath);
Image tmpcrop = Image.fromBitmap(tmp);
frame.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
frame.setImageDrawable(tmpcrop.toDrawable());
}
}
XML crop
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<net.tredio.elecgal.editactivity.CropImageView
android:id="@+id/cropview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="fitCenter"
/>
</LinearLayout>
머를 잘못 한걸까요??ㅜㅜ
아시는분 아이유같은 여친생기실꺼에요~!!
에러는 이렇습니다
04-06 14:15:18.169: ERROR/AndroidRuntime(22037): java.lang.RuntimeException: Unable to start activity ComponentInfo{net.tredio.elecgal/net.tredio.elecgal.editactivity.CropActivity}: android.view.InflateException: Binary XML file line #15: Error inflating class net.tredio.elecgal.editactivity.CropImageView
CropImageView.java
public class CropImageView extends ImageView {
private DragAndDropEvent event = new DragAndDropEvent();
private OnDragAndDropListener listener;
public CropImageView(Context context) {
super(context);
}
@Override
public boolean onTouchEvent(MotionEvent event){
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
this.event.start.setMotionEvent(event);
break;
case MotionEvent.ACTION_UP:
this.event.end.setMotionEvent(event);
if (listener != null) {
listener.onDragAndDropEvent(this.event);
}
break;
}
return true;
}
}
CropActivity.java
public class CropActivity extends Activity{
private static String log = "CropActivity";
Image image ;
CropImageView frame ;
Bitmap modbitmap ;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.crop);
frame = new CropImageView(CropActivity.this);
frame = (CropImageView) findViewById(R.id.cropview);
Intent intent = getIntent();
String temppath = intent.getStringExtra("temppath");
Bitmap tmp = BitmapFactory.decodeFile(temppath);
Image tmpcrop = Image.fromBitmap(tmp);
frame.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
frame.setImageDrawable(tmpcrop.toDrawable());
}
}
XML crop
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<net.tredio.elecgal.editactivity.CropImageView
android:id="@+id/cropview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="fitCenter"
/>
</LinearLayout>




아마 생성자 쪽에서 문제가 생긴 것 같네요~
CropImageView class에 생성자 추가 하시면 될듯도 싶네요.. 한번 해 보세요
public CropImageView (Context context, AttributeSet attrs)
{
super(context, attrs);
// TODO Auto-generated constructor stub
}
/**
* @param context
* @param attrs
* @param defStyle
*/
public CropImageView (Context context, AttributeSet attrs, int defStyle)
{
super(context, attrs, defStyle);
// TODO Auto-generated constructor stub
}
그리고
frame = new CropImageView(CropActivity.this);
이부분은 필요 없을듯 하네요 ^^