简体   繁体   English

运行应用程序时 setContentView() 出现问题,它不起作用

[英]problem in setContentView() when I am running the application, it does not work

package com.example.uberapp;

import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.AppCompatTextView;

import android.content.Context;
import android.os.Bundle;

import uk.co.chrisjenx.calligraphy.CalligraphyConfig;
import uk.co.chrisjenx.calligraphy.CalligraphyContextWrapper;

public class MainActivity extends AppCompatActivity {


    @Override
    protected void attachBaseContext(Context newBase) {
        super.attachBaseContext(CalligraphyContextWrapper.wrap(newBase));
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);


        CalligraphyConfig.initDefault(new CalligraphyConfig.Builder()
                                       .setDefaultFontPath("fonts/Arkhip_font.ttf")
                                    .addCustomStyle(AppCompatTextView.class,android.R.attr.textViewStyle)
                                     .setFontAttrId(R.attr.fontPath)
                                        .build());
        setContentView(R.activity_main);


    }
}

try with尝试

setContentView(R.layout.activity_main);

this is proper layout declaration ( R.layout prefix)这是正确的layout声明( R.layout前缀)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM