简体   繁体   中英

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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