내가 CustomUI.java 내가 제작하는 주문형 UI
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.missedcall"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="16" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.missedcall.CustomUI"
android:label="@string/title_activity_custom_ui" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
내가 AndroidManifest.xml을
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".CustomUI" >
<com.example.missedcall.CustomUI
android:id="@+id/single_spinner"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true" >
</com.example.missedcall.CustomUI>
</RelativeLayout>
를 레이아웃 custom_ui.xml 파일을 만든
public class CustomUI extends View {
Bitmap icon;
float left=0;
public CustomUI(Context context) {
super(context);
icon=BitmapFactory.decodeResource(getResources(), R.drawable.icon);
}
@Override
protected void onDraw(Canvas canvas) {
// TODO Auto-generated method stub
super.onDraw(canvas);
canvas.drawBitmap(icon, left, 0, null);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
setMeasuredDimension(250, 100);
}
@Override
public boolean onTouchEvent(MotionEvent event) {
// TODO Auto-generated method stub
if(event.getAction()==event.ACTION_SCROLL){
left=event.getX();
}
if(left>=200){
//do some activity;
}
return true;
}
}
파일을 만든 (기준보기를 확장) 보여 주는 그래픽 레이아웃을 잘 보여 주지만, 실행할 때 실행 n은 빈 레이아웃을 표시하고 두 번째 nc 이후에 오류를 표시합니다. 앱을 잃어 버린다. 이 문제를 해결하고 Android에서 맞춤 UI를 만드는 데 도움을주세요.
로그 파일 : http://i.stack.imgur.com/o4L6o.jpg 또는 https://dl.dropboxusercontent.com/u/6608612/log.JPG
이 생성자가 될 수 ..
희망이 도움으로 CustomUi를 선언? 따라 나는 그것을 변경 –