안드로이드 만드는 법 2.2 안드로이드 4에서 작동하는 앱? 훌륭한 리팩토링 작품입니까? 아니면 프로젝트에서 변경해야 할 sdk 설정입니까?안드로이드 만드는 방법 2.2 애플 리케이션은 안드로이드 4에서 작동합니까?
BTW : 더 좋은 경우 : - android 4와 호환되는 android 2.2 app? - Google의 호환성 패키지가 포함 된 Android 4 앱?
미리 감사드립니다.
E/AndroidRuntime( 660): FATAL EXCEPTION: main
E/AndroidRuntime( 660): java.lang.RuntimeException: Unable to start activity ComponentInfo{vex.android/vex.android.controllers.ControllerLoginView}: java.lang.NullPointerException
E/AndroidRuntime( 660): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
E/AndroidRuntime( 660): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
E/AndroidRuntime( 660): at android.app.ActivityThread.access$600(ActivityThread.java:123)
E/AndroidRuntime( 660): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
E/AndroidRuntime( 660): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 660): at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime( 660): at android.app.ActivityThread.main(ActivityThread.java:4424)
E/AndroidRuntime( 660): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 660): at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime( 660): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
E/AndroidRuntime( 660): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
E/AndroidRuntime( 660): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 660): Caused by: java.lang.NullPointerException
E/AndroidRuntime( 660): at vex.android.layout.layout_titleheader.setButtonVisibility(layout_titleheader.java:163)
E/AndroidRuntime( 660): at vex.android.layout.layout_titleheader.setButtonVisibility(layout_titleheader.java:155)
E/AndroidRuntime( 660): at vex.android.controllers.ControllerLoginView.Initialize(ControllerLoginView.java:58)
E/AndroidRuntime( 660): at vex.android.definition.VexActivity.onStart(VexActivity.java:154)
E/AndroidRuntime( 660): at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1133)
E/AndroidRuntime( 660): at android.app.Activity.performStart(Activity.java:4475)
E/AndroidRuntime( 660): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1929)
E/AndroidRuntime( 660): ... 11 more
layout_titleheader.java :
package vex.android.layout;
import vex.android.R;
import vex.android.controllers.ControllerInfo;
import vex.android.definition.VexLayout;
import vex.android.definition.iVexParentable;
import vex.android.definition.intentCode;
import android.app.Activity;
import android.app.Instrumentation;
import android.content.Context;
import android.content.Intent;
import android.os.Handler;
import android.os.SystemClock;
import android.util.AttributeSet;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ImageView;
public class layout_titleheader extends VexLayout
{
/*** CONTROL POINTERS ***/
Button nextButton;
Button prevButton;
ImageView infoButton;
ImageButton upButton;
ImageButton downButton;
private Handler handler = new Handler();
private Runnable upTask = new Runnable() {
public void run() {
if(getContext() instanceof iVexParentable) {
((iVexParentable)getContext()).onUpButton();
}
handler.postAtTime(this, SystemClock.uptimeMillis() + 100);
}
};
private Runnable downTask = new Runnable() {
public void run() {
if(getContext() instanceof iVexParentable) {
((iVexParentable)getContext()).onDownButton();
}
handler.postAtTime(this, SystemClock.uptimeMillis() + 100);
}
};
/**** CONSTRUCTORS ****/
public layout_titleheader(Context context)
{
super(context);
((Activity)getContext()).getLayoutInflater().inflate(R.layout.layout_titleheader, this);
}
public layout_titleheader(Context context, AttributeSet attrs) {
super(context, attrs);
((Activity)getContext()).getLayoutInflater().inflate(R.layout.layout_titleheader, this);
}
/**** INITIALIZERS ****/
@Override
public void Initialize()
{
infoButton.setOnTouchListener(new OnTouchListener(){
@Override
public boolean onTouch(View v, MotionEvent event) {
if(event.getAction() == MotionEvent.ACTION_DOWN)
{
showInfo();
}
return true;
}
});
prevButton.setOnTouchListener(new OnTouchListener(){
@Override
public boolean onTouch(View v, MotionEvent event) {
if(event.getAction() == MotionEvent.ACTION_DOWN)
{
new Thread(new Runnable() {
@Override
public void run() {
Instrumentation i = new Instrumentation();
i.sendKeyDownUpSync(KeyEvent.KEYCODE_BACK);
}
}).start();
}
return true;
}
});
nextButton.setOnTouchListener(new OnTouchListener(){
@Override
public boolean onTouch(View v, MotionEvent event) {
if(event.getAction() == MotionEvent.ACTION_DOWN)
{
if(getContext() instanceof iVexParentable)
{
((iVexParentable)getContext()).onEditButton();
}
}
return true;
}
});
upButton.setOnTouchListener(new OnTouchListener() {
public boolean onTouch(View view, MotionEvent motionevent) {
int action = motionevent.getAction();
if (action == MotionEvent.ACTION_DOWN) {
handler.removeCallbacks(upTask);
handler.postAtTime(upTask, SystemClock.uptimeMillis() + 100);
} else if (action == MotionEvent.ACTION_UP) {
handler.removeCallbacks(upTask);
}
return false;
}
});
downButton.setOnTouchListener(new OnTouchListener(){
@Override
public boolean onTouch(View v, MotionEvent motionevent) {
int action = motionevent.getAction();
if (action == MotionEvent.ACTION_DOWN) {
handler.removeCallbacks(downTask);
handler.postAtTime(downTask, SystemClock.uptimeMillis() + 100);
} else if (action == MotionEvent.ACTION_UP) {
handler.removeCallbacks(downTask);
}
return false;
}
});
}
@Override
public void InitializeControls()
{
infoButton = (ImageView)findViewById(R.id.infoButton);
prevButton = (Button)findViewById(R.id.prevButton);
nextButton = (Button)findViewById(R.id.nextButton);
upButton = (ImageButton)findViewById(R.id.upButton);
downButton = (ImageButton)findViewById(R.id.downButton);
}
/**** LOCAL METHODS ****/
public void showInfo()
{
if(getContext() instanceof Activity)
{
Intent intent = new Intent(getContext(), ControllerInfo.class);
((Activity)getContext()).startActivityForResult(intent, intentCode.INFO_DOSTART);
}
}
public void setButtonVisibility(int previousButton, int editButton, int helpButton)
{
setButtonVisibility(previousButton, editButton, helpButton, View.INVISIBLE, View.INVISIBLE);
}
public void setButtonVisibility(int previousButton, int editButton, int helpButton, int upButtonVisibility, int downButtonVisibility)
{
if (View.VISIBLE == previousButton) {// fixes issue of translation not correctly displayed
prevButton.setText(getContext().getString(R.string.Back));
}
prevButton.setVisibility(previousButton);
nextButton.setVisibility(editButton);
infoButton.setVisibility(helpButton);
upButton.setVisibility(upButtonVisibility);
downButton.setVisibility(downButtonVisibility);
}
public void setPreviousButtonText(int id) {
prevButton.setText(getContext().getString(id));
}
public void setEditButtonName(int resId)
{
nextButton.setText(resId);
}
}
는 편집 : 내 응용 프로그램은 안드로이드 4.
스택 트레이스에 안드로이드 2.2 및 2.3하지만 충돌에서 잘 실행되기 때문에 나는이 물어 일부 파기 후, 나는 VexLayout에서 오버라이드 된 View 클래스의 onFinishInflate()가 안드로이드를 실행할 때 호출되지 않는다는 것을 알게되었다. 4. 어떤 생각?
하면 방법 setButtonVisibility (INT, INT, int, int, int)에있는 널 널 (null),
getContext
또는Context.getString(int)
반환 같은지 여부를 확인하는 당신이 충돌의 스택 덤프를 제공하면 누군가가 당신을 도울 수 있습니다. – mah'layout_titleheader.java'를 보여주십시오. – pepyakin
질문에 추가했습니다. – Alexis