사용자의 사례 수와 청구서 비용을 입력하는 클래스 용 앱을 만들어야하고 비용이 무엇인지 알려줍니다. 사람이 팁을 추가했습니다. 그것은 작동해야하지만 그것은 내가 확신이 새로운 그래서 오전 매번 나는 에뮬레이터를 실행하면 내 애플 리케이션이 작동을 멈추었다 고 말하고 계속 실행됩니다. 여기 내 코드입니다. 위로 첫 번째 mainactivity. 사람이 그 좋지 않을까 도움이 될 수있는 경우에뮬레이터를 실행할 때 내 안드로이드 앱이 계속 충돌합니다.
package com.example.splitbill;
import android.support.v7.app.ActionBarActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class MainActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button b = (Button) findViewById(R.id.btnCalc);
b.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
startActivity(new Intent(MainActivity.this, Calc.class));
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
다음 내 두 번째 활동 석회질
package com.example.splitbill;
import java.text.DecimalFormat;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.TextView;
public class Calc extends Activity {
double totalOfBill;
int numberOfGuests;
double perPersonSplit;
String groupChoice;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.calc);
final EditText guests=(EditText)findViewById(R.id.txtGuests);
final EditText bill=(EditText)findViewById(R.id.txtBill);
final Spinner group = (Spinner)findViewById(R.id.txtGroup);
Button cost = (Button)findViewById(R.id.btnSplit);
cost.setOnClickListener(new OnClickListener() {
final TextView result = ((TextView)findViewById(R.id.txtResult));
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
totalOfBill = Double.parseDouble(bill.getText().toString());
numberOfGuests = Integer.parseInt(guests.getText().toString());
perPersonSplit = (totalOfBill * .18 +totalOfBill)/numberOfGuests;
DecimalFormat currency = new DecimalFormat("$###,###.##");
groupChoice = group.getSelectedItem().toString();
result.setText("Quality is " + groupChoice + "cost is " + currency.format(perPersonSplit));
}
});
}
}
이라고한다. 어떤 사람이 내가
02-03 16:53:14.297: D/AndroidRuntime(1043): Shutting down VM
02-03 16:53:14.297: D/AndroidRuntime(1043): --------- beginning of crash
02-03 16:53:14.312: E/AndroidRuntime(1043): FATAL EXCEPTION: main
02-03 16:53:14.312: E/AndroidRuntime(1043): Process: com.example.splitbill, PID: 1043
02-03 16:53:14.312: E/AndroidRuntime(1043): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.splitbill/com.example.splitbill.MainActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
02-03 16:53:14.312: E/AndroidRuntime(1043): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298)
02-03 16:53:14.312: E/AndroidRuntime(1043): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
02-03 16:53:14.312: E/AndroidRuntime(1043): at android.app.ActivityThread.access$800(ActivityThread.java:144)
02-03 16:53:14.312: E/AndroidRuntime(1043): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
02-03 16:53:14.312: E/AndroidRuntime(1043): at android.os.Handler.dispatchMessage(Handler.java:102)
02-03 16:53:14.312: E/AndroidRuntime(1043): at android.os.Looper.loop(Looper.java:135)
02-03 16:53:14.312: E/AndroidRuntime(1043): at android.app.ActivityThread.main(ActivityThread.java:5221)
02-03 16:53:14.312: E/AndroidRuntime(1043): at java.lang.reflect.Method.invoke(Native Method)
02-03 16:53:14.312: E/AndroidRuntime(1043): at java.lang.reflect.Method.invoke(Method.java:372)
02-03 16:53:14.312: E/AndroidRuntime(1043): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
02-03 16:53:14.312: E/AndroidRuntime(1043): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
02-03 16:53:14.312: E/AndroidRuntime(1043): Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
02-03 16:53:14.312: E/AndroidRuntime(1043): at android.support.v7.app.ActionBarActivityDelegate.onCreate(ActionBarActivityDelegate.java:151)
02-03 16:53:14.312: E/AndroidRuntime(1043): at android.support.v7.app.ActionBarActivityDelegateBase.onCreate(ActionBarActivityDelegateBase.java:138)
02-03 16:53:14.312: E/AndroidRuntime(1043): at android.support.v7.app.ActionBarActivity.onCreate(ActionBarActivity.java:123)
02-03 16:53:14.312: E/AndroidRuntime(1043): at com.example.splitbill.MainActivity.onCreate(MainActivity.java:16)
02-03 16:53:14.312: E/AndroidRuntime(1043): at android.app.Activity.performCreate(Activity.java:5933)
02-03 16:53:14.312: E/AndroidRuntime(1043): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
02-03 16:53:14.312: E/AndroidRuntime(1043): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
02-03 16:53:14.312: E/AndroidRuntime(1043): ... 10 more
오류 로그 표시 – Nickolaus
오류 로그를 추가했습니다. –
[이 활동과 함께 Theme.AppCompat 테마 (또는 자손)를 사용해야합니다.] (http://stackoverflow.com/questions/21814825/you) -need-to-use-a-theme-appcompat-theme-or-descend-with-this-activity) – njzk2