我没有带下划线的代码,但只要我在模拟器上启动我的应用程序,就会收到这些错误。
public class SplashActivity extends AppCompatActivity {
private TextView etSportisa;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
/* ButterKnife.inject(this);
mProgressBar.setIndeterminateDrawable(new foldingCirclesDrawable.Builder(this)
.build());
mProgressBar.setIndeterminateDrawable(new foldingCirclesDrawable.Builder(this)
.colors(getResources().getIntArray(R.array.colors) //Array of 4 colors
.build()); */
Typeface myTypeFace = Typeface.createFromAsset(getAssets(), "fonts/esp_ital.ttf");
etSportisa.setTypeface(myTypeFace);
etSportisa = (TextView) findViewById(R.id.tv_sportisa);
final ProgressDialog pd = new ProgressDialog(SplashActivity.this);
pd.setMessage("Učitavanje...");
pd.show();
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
public void run() {
// Actions to do after 10 seconds
pd.dismiss();
Intent i = new Intent(SplashActivity.this, MainActivity.class);
startActivity(i);
}
}, 2000);
}
}
这是我的SplashActivity:
generics.ListAPIView
在assets \ font文件夹中添加特殊字体。我还为加载屏幕添加了一个图像,但我认为该字体是这些问题的表亲
答案 0 :(得分:8)
对您的代码进行以下更改:
Typeface myTypeFace = Typeface.createFromAsset(getAssets(), "fonts/esp_ital.ttf");
etSportisa = (TextView) findViewById(R.id.tv_sportisa);
etSportisa.setTypeface(myTypeFace);
初始化后,您可以使用任何布局进行任何操作。
答案 1 :(得分:1)
问题在于:
etSportisa
为空
在findViewByID
Typeface myTypeFace = Typeface.createFromAsset(getAssets(), "fonts/esp_ital.ttf");
etSportisa = (TextView) findViewById(R.id.tv_sportisa);
etSportisa.setTypeface(myTypeFace);