为什么eclipse不让我编译这个。我想让自己点击一个按钮,然后Edittext
数据转到Textview
. 然后从那里我希望textView
通过按另一个将其转换为条形码Button
,所以我总共有 2Buttons
和 2textViews
和 1editTexts
请告诉如何做到这一点或我哪里错了
public class cc extends Activity {
EditText inputc;
TextView outputc;
TextView tv1;
ImageView iv;
Button b;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.cc);
inputc = (EditText) findViewById(R.id.ccinput);
outputc = (TextView) findViewById(R.id.outputc);
Button send = (Button) findViewById(R.id.button);
final TextView tv1 = (TextView) findViewById(R.id.outputc);
tv1.setDrawingCacheEnabled(true);
//To change to code 39 barCode font
Typeface barcodefont = Typeface.createFromAsset(getAssets(), "fonts/IDAutomationHC39M_FREE.otf");
TextView tv = (TextView) findViewById(R.id.outputc);
tv.setTypeface(barcodefont);
send.setOnClickListener (new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
tv1.buildDrawingCache();
iv.setImageBitmap(tv1.getDrawingCache());
outputc.setText((inputc.getText()));
}
});
}
}
附加信息。我已经编译了,但现在我得到了错误,这里是 logcat:
10-16 15:41:11.095: E/AndroidRuntime(5822): FATAL EXCEPTION: main
10-16 15:41:11.095: E/AndroidRuntime(5822): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.barcodedisplayer/com.example.barcodedisplayer.cc}: java.lang.RuntimeException: native typeface cannot be made
10-16 15:41:11.095: E/AndroidRuntime(5822): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2355)
10-16 15:41:11.095: E/AndroidRuntime(5822): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2405)
10-16 15:41:11.095: E/AndroidRuntime(5822): at android.app.ActivityThread.access$600(ActivityThread.java:156)
10-16 15:41:11.095: E/AndroidRuntime(5822): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1272)
10-16 15:41:11.095: E/AndroidRuntime(5822): at android.os.Handler.dispatchMessage(Handler.java:99)
10-16 15:41:11.095: E/AndroidRuntime(5822): at android.os.Looper.loop(Looper.java:137)
10-16 15:41:11.095: E/AndroidRuntime(5822): at android.app.ActivityThread.main(ActivityThread.java:5303)
10-16 15:41:11.095: E/AndroidRuntime(5822): at java.lang.reflect.Method.invokeNative(Native Method)
10-16 15:41:11.095: E/AndroidRuntime(5822): at java.lang.reflect.Method.invoke(Method.java:525)
10-16 15:41:11.095: E/AndroidRuntime(5822): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:739)
10-16 15:41:11.095: E/AndroidRuntime(5822): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:555)
10-16 15:41:11.095: E/AndroidRuntime(5822): at dalvik.system.NativeStart.main(Native Method)
10-16 15:41:11.095: E/AndroidRuntime(5822): Caused by: java.lang.RuntimeException: native typeface cannot be made
10-16 15:41:11.095: E/AndroidRuntime(5822): at android.graphics.Typeface.<init>(Typeface.java:175)
10-16 15:41:11.095: E/AndroidRuntime(5822): at android.graphics.Typeface.createFromAsset(Typeface.java:149)
10-16 15:41:11.095: E/AndroidRuntime(5822): at com.example.barcodedisplayer.cc.onCreate(cc.java:32)
10-16 15:41:11.095: E/AndroidRuntime(5822): at android.app.Activity.performCreate(Activity.java:5207)
10-16 15:41:11.095: E/AndroidRuntime(5822): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
10-16 15:41:11.095: E/AndroidRuntime(5822): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2309)
10-16 15:41:11.095: E/AndroidRuntime(5822): ... 11 more