How can I change the font type in a fragment [Android]

0

How about, I have problems to change the type of source, it turns out that I create a folder called "assets" and that's where I keep my types of sources, the problem is that only fragments do not recognize this folder, instead in the activitys if they recognize it.

PagosFragment.kt

package com.example.gonzalo.proyecto_android_2018.fragments


import android.content.Intent
import android.graphics.Typeface
import android.os.Bundle
import android.support.v4.app.Fragment
import android.support.v7.widget.Toolbar
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup

import com.example.gonzalo.proyecto_android_2018.R
import kotlinx.android.synthetic.main.activity_navigation.*

class PagosFragment : Fragment() {

lateinit var script: Typeface

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
                          savedInstanceState: Bundle?): View? {

    var fuente:String = "Arvo_Bold.ttf"
    script = Typeface.createFromAsset(assets, fuente) //Me salta un error en "assets"


    // Inflate the layout for this fragment
    return inflater.inflate(R.layout.fragment_pagos, container, false)

    var tb: Toolbar= toolbar as Toolbar

    tb.setNavigationIcon(R.drawable.ic_volver)

    tb.setNavigationOnClickListener{
        val intent = Intent(context, HomeFragment::class.java)
        startActivity(intent)
    }
}

}

Image of the assets folder

LogCat

11/18 20:41:40: Launching app
$ adb push D:\WorkSpaces\Mi_Parte_Del_Proyecto_Android_Firebase_LISTO\app\build\outputs\apk\debug\app-debug.apk /data/local/tmp/com.example.gonzalo.proyecto_android_2018
$ adb shell pm install -t -r "/data/local/tmp/com.example.gonzalo.proyecto_android_2018"
    pkg: /data/local/tmp/com.example.gonzalo.proyecto_android_2018
Success


$ adb shell am start -n "com.example.gonzalo.proyecto_android_2018/com.example.gonzalo.proyecto_android_2018.activities.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Client not ready yet..Connected to process 31874 on device samsung-sm_j120m-4200a7d4c42123f7
Capturing and displaying logcat messages from application. This behavior can be disabled in the "Logcat output" section of the "Debugger" settings page.
E/Zygote: MountEmulatedStorage()
          v2
I/SELinux: Function: selinux_compare_spd_ram , priority [2] , priority version is VE=SEPF_SM-J120M_5.1.1_0073
I/libpersona: KNOX_SDCARD checking this for 10126
              KNOX_SDCARD not a persona
E/Zygote: accessInfo : 0
E/SELinux: [DEBUG] get_category: variable seinfo: default sensitivity: NULL, cateogry: NULL
I/art: Late-enabling -Xcheck:jni
D/TimaKeyStoreProvider: TimaSignature is unavailable
D/ActivityThread: Added TimaKeyStore provider
I/MultiDex: VM with version 2.1.0 has multidex support
            Installing application
            VM has multidex support, MultiDex support library is disabled.
V/FA: Registered activity lifecycle callback
D/FirebaseApp: com.google.firebase.auth.FirebaseAuth is not linked. Skipping initialization.
               com.google.firebase.crash.FirebaseCrash is not linked. Skipping initialization.
I/FirebaseInitProvider: FirebaseApp initialization successful
W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
V/FA: onActivityCreated
D/PhoneWindow: *FMB* installDecor mIsFloating : false
D/PhoneWindow: *FMB* installDecor flags : -2139029248
I/art: Background sticky concurrent mark sweep GC freed 9786(538KB) AllocSpace objects, 0(0B) LOS objects, 7% free, 5MB/6MB, paused 5.319ms total 104.762ms
D/TextView: setTypeface with style : 0
D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: false
D/PhoneWindow: *FMB* isFloatingMenuEnabled mFloatingMenuBtn : null
               *FMB* isFloatingMenuEnabled return false
W/System.err: remove failed: ENOENT (No such file or directory) : /data/data/com.example.gonzalo.proyecto_android_2018/shared_prefs/com.google.android.gms.measurement.prefs.xml.bak
D/libEGL: eglInitialize EGLDisplay = 0xa0acdc54
I/OpenGLRenderer: Initialized EGL, version 1.4
I/OpenGLRenderer: HWUI protection enabled for context ,  &this =0xaf82f7f0 ,&mEglDisplay = 1 , &mEglConfig = -1349348708 
D/OpenGLRenderer: Get maximum texture size. GL_MAX_TEXTURE_SIZE is 8192
                  Enabling debug mode 0
D/mali_winsys: new_window_surface returns 0x3000,  [480x800]-format:1
I/Timeline: Timeline: Activity_idle id: [email protected] time:7900782
V/FA: Collection enabled
V/FA: App package, google app id: com.example.gonzalo.proyecto_android_2018, 1:5865361174:android:96e7d42775d63500
I/FA: App measurement is starting up, version: 13001
      To enable debug logging run: adb shell setprop log.tag.FA VERBOSE
I/FA: To enable faster debug mode event logging run:
        adb shell setprop debug.firebase.analytics.app com.example.gonzalo.proyecto_android_2018
D/FA: Debug-level message logging enabled
V/FA: Persisting first open: 1542591740171
V/FA: Updating deferred analytics collection: false
W/System.err: remove failed: ENOENT (No such file or directory) : /data/data/com.example.gonzalo.proyecto_android_2018/shared_prefs/com.google.android.gms.appid.xml.bak
V/FA: Checking service availability
V/FA: Service available
      Setting useService: true
V/FA: Connecting to remote service
V/FA: Connection attempt already in progress
I/FA: Tag Manager is not found and thus will not be used
D/FA: Logging event (FE): screen_view(_vs), Bundle[{firebase_event_origin(_o)=auto, firebase_screen_class(_sc)=MainActivity, firebase_screen_id(_si)=-6734034309360283614}]
V/FA: Connection attempt already in progress
      Connection attempt already in progress
V/FA: Activity resumed, time: 29072063
D/FA: Connected to remote service
V/FA: Processing queued up service tasks: 4
I/Timeline: Timeline: Activity_launch_request id:com.example.gonzalo.proyecto_android_2018 time:7905315
V/FA: onActivityCreated
D/PhoneWindow: *FMB* installDecor mIsFloating : false
               *FMB* installDecor flags : -2139029248
D/TextView: setTypeface with style : 0
D/TextView: setTypeface with style : 0
D/TextView: setTypeface with style : 0
D/TextView: setTypeface with style : 0
V/FA: Recording user engagement, ms: 5778
V/FA: Activity paused, time: 29077178
D/FA: Logging event (FE): user_engagement(_e), Bundle[{firebase_event_origin(_o)=auto, engagement_time_msec(_et)=5778, firebase_screen_class(_sc)=MainActivity, firebase_screen_id(_si)=-6734034309360283614}]
I/Choreographer: Skipped 42 frames!  The application may be doing too much work on its main thread.
D/PhoneWindow: *FMB* isFloatingMenuEnabled mFloatingMenuBtn : null
               *FMB* isFloatingMenuEnabled return false
D/mali_winsys: new_window_surface returns 0x3000,  [480x800]-format:1
E/FirebaseInstanceId: Failed to resolve target intent service, skipping classname enforcement
E/FirebaseInstanceId: Error while delivering the message: ServiceIntent not found.
D/FA: Logging event (FE): screen_view(_vs), Bundle[{firebase_event_origin(_o)=auto, firebase_previous_class(_pc)=MainActivity, firebase_previous_id(_pi)=-6734034309360283614, firebase_screen_class(_sc)=ViajaDestinoActivity, firebase_screen_id(_si)=3523377130946130506}]
V/FA: Activity resumed, time: 29077894
I/Timeline: Timeline: Activity_idle id: [email protected] time:7906574
V/ActivityThread: updateVisibility : ActivityRecord{a508950 [email protected] {com.example.gonzalo.proyecto_android_2018/com.example.gonzalo.proyecto_android_2018.activities.MainActivity}} show : false
V/FA: Session started, time: 29083079
D/FA: Setting user property (FE): _sid
D/FA: Logging event (FE): session_start(_s), Bundle[{firebase_event_origin(_o)=auto, firebase_screen_class(_sc)=ViajaDestinoActivity, firebase_screen_id(_si)=3523377130946130506}]
V/FA: Inactivity, disconnecting from the service
D/ViewRootImpl: ViewPostImeInputStage ACTION_DOWN
I/Timeline: Timeline: Activity_launch_request id:com.example.gonzalo.proyecto_android_2018 time:8008497
V/FA: Recording user engagement, ms: 102402
      Connecting to remote service
V/FA: Activity paused, time: 29180295
V/FA: onActivityCreated
D/FA: Logging event (FE): user_engagement(_e), Bundle[{firebase_event_origin(_o)=auto, engagement_time_msec(_et)=102402, firebase_screen_class(_sc)=ViajaDestinoActivity, firebase_screen_id(_si)=3523377130946130506}]
D/PhoneWindow: *FMB* installDecor mIsFloating : false
               *FMB* installDecor flags : -2139029248
V/FA: Connection attempt already in progress
D/TextView: setTypeface with style : 0
D/TextView: setTypeface with style : 0
D/TextView: setTypeface with style : 0
D/TextView: setTypeface with style : 0
            setTypeface with style : 0
D/TextView: setTypeface with style : 0
D/TextView: setTypeface with style : 0
D/TextView: setTypeface with style : 0
D/PhoneWindow: *FMB* isFloatingMenuEnabled mFloatingMenuBtn : null
               *FMB* isFloatingMenuEnabled return false
D/FA: Logging event (FE): screen_view(_vs), Bundle[{firebase_event_origin(_o)=auto, firebase_previous_class(_pc)=ViajaDestinoActivity, firebase_previous_id(_pi)=3523377130946130506, firebase_screen_class(_sc)=LoginActivity, firebase_screen_id(_si)=3523377130946130507}]
V/FA: Connection attempt already in progress
      Connection attempt already in progress
      Activity resumed, time: 29180512
D/mali_winsys: new_window_surface returns 0x3000,  [480x800]-format:1
D/FA: Connected to remote service
V/FA: Processing queued up service tasks: 4
I/Timeline: Timeline: Activity_idle id: [email protected] time:8009157
V/ActivityThread: updateVisibility : ActivityRecord{17629dce [email protected] {com.example.gonzalo.proyecto_android_2018/com.example.gonzalo.proyecto_android_2018.activities.ViajaDestinoActivity}} show : false
D/ViewRootImpl: ViewPostImeInputStage ACTION_DOWN
I/Timeline: Timeline: Activity_launch_request id:com.example.gonzalo.proyecto_android_2018 time:8012473
V/FA: Recording user engagement, ms: 3756
V/FA: Activity paused, time: 29184268
D/FA: Logging event (FE): user_engagement(_e), Bundle[{firebase_event_origin(_o)=auto, engagement_time_msec(_et)=3756, firebase_screen_class(_sc)=LoginActivity, firebase_screen_id(_si)=3523377130946130507}]
V/FA: onActivityCreated
D/PhoneWindow: *FMB* installDecor mIsFloating : false
               *FMB* installDecor flags : -2139029248
W/Firestore: (0.6.6-dev) [Firestore]: The behavior for java.util.Date objects stored in Firestore is going to change AND YOUR APP MAY BREAK.
             To hide this warning and ensure your app does not break, you need to add the following code to your app before calling any other Cloud Firestore methods:

             FirebaseFirestore firestore = FirebaseFirestore.getInstance();
             FirebaseFirestoreSettings settings = new FirebaseFirestoreSettings.Builder()
                 .setTimestampsInSnapshotsEnabled(true)
                 .build();
             firestore.setFirestoreSettings(settings);

             With this change, timestamps stored in Cloud Firestore will be read back as com.google.firebase.Timestamp objects instead of as system java.util.Date objects. So you will also need to update code expecting a java.util.Date to instead expect a Timestamp. For example:

             // Old:
             java.util.Date date = snapshot.getDate("created_at");
             // New:
             Timestamp timestamp = snapshot.getTimestamp("created_at");
             java.util.Date date = timestamp.toDate();

             Please audit all existing usages of java.util.Date when you enable the new behavior. In a future release, the behavior will be changed to the new behavior, so if you do not follow these steps, YOUR APP MAY BREAK.
W/ResourcesManager: Asset path '/system/framework/com.android.media.remotedisplay.jar' does not exist or contains no resources.
                    Asset path '/system/framework/com.android.location.provider.jar' does not exist or contains no resources.
D/PhoneWindow: *FMB* isFloatingMenuEnabled mFloatingMenuBtn : null
               *FMB* isFloatingMenuEnabled return false
D/FA: Logging event (FE): screen_view(_vs), Bundle[{firebase_event_origin(_o)=auto, firebase_previous_class(_pc)=LoginActivity, firebase_previous_id(_pi)=3523377130946130507, firebase_screen_class(_sc)=NavigationActivity, firebase_screen_id(_si)=3523377130946130508}]
D/mali_winsys: new_window_surface returns 0x3000,  [480x800]-format:1
V/FA: Activity resumed, time: 29184697
D/TextView: setTypeface with style : 0
D/TextView: setTypeface with style : 0
D/TextView: setTypeface with style : 0
W/linker: libconscrypt_gmscore_jni.so: unused DT entry: type 0x6ffffffe arg 0x151c
          libconscrypt_gmscore_jni.so: unused DT entry: type 0x6fffffff arg 0x2
D/TextView: setTypeface with style : 0
D/TextView: setTypeface with style : 0
V/NativeCrypto: Registering com/google/android/gms/org/conscrypt/NativeCrypto's 287 native methods...
D/TextView: setTypeface with style : 0
I/Timeline: Timeline: Activity_idle id: [email protected] time:8013212
I/art: Rejecting re-init on previously-failed class java.lang.Class<com.google.android.gms.org.conscrypt.Java7ExtendedSSLSession>
       Rejecting re-init on previously-failed class java.lang.Class<com.google.android.gms.org.conscrypt.Java7ExtendedSSLSession>
I/art: Rejecting re-init on previously-failed class java.lang.Class<com.google.android.gms.org.conscrypt.Java8ExtendedSSLSession>
       Rejecting re-init on previously-failed class java.lang.Class<com.google.android.gms.org.conscrypt.Java8ExtendedSSLSession>
I/ProviderInstaller: Installed default security provider GmsCore_OpenSSL
V/ActivityThread: updateVisibility : ActivityRecord{35cf4dac [email protected] {com.example.gonzalo.proyecto_android_2018/com.example.gonzalo.proyecto_android_2018.activities.LoginActivity}} show : false
W/System.err: remove failed: ENOENT (No such file or directory) : /data/data/com.example.gonzalo.proyecto_android_2018/cache/picasso-cache/journal
              remove failed: ENOENT (No such file or directory) : /data/data/com.example.gonzalo.proyecto_android_2018/cache/picasso-cache/journal.bkp
W/System.err: remove failed: ENOENT (No such file or directory) : /data/data/com.example.gonzalo.proyecto_android_2018/cache/picasso-cache/3eda67812c720d188f99c04c1c7929c3.0
              remove failed: ENOENT (No such file or directory) : /data/data/com.example.gonzalo.proyecto_android_2018/cache/picasso-cache/3eda67812c720d188f99c04c1c7929c3.1
W/System.err: remove failed: ENOENT (No such file or directory) : /data/data/com.example.gonzalo.proyecto_android_2018/cache/picasso-cache/5cb1d09079c0157b78d096df2a73f505.0
W/System.err: remove failed: ENOENT (No such file or directory) : /data/data/com.example.gonzalo.proyecto_android_2018/cache/picasso-cache/5cb1d09079c0157b78d096df2a73f505.1
W/System.err: remove failed: ENOENT (No such file or directory) : /data/data/com.example.gonzalo.proyecto_android_2018/cache/picasso-cache/2bbaea7f89ed928326898c7baae7bdf9.0
              remove failed: ENOENT (No such file or directory) : /data/data/com.example.gonzalo.proyecto_android_2018/cache/picasso-cache/2bbaea7f89ed928326898c7baae7bdf9.1
D/ViewRootImpl: ViewPostImeInputStage ACTION_DOWN
D/ViewRootImpl: ViewPostImeInputStage ACTION_DOWN
V/FA: Inactivity, disconnecting from the service
D/ViewRootImpl: ViewPostImeInputStage ACTION_DOWN
D/TextView: setTypeface with style : 0
D/TextView: setTypeface with style : 0
D/TextView: setTypeface with style : 0
D/TextView: setTypeface with style : 0
D/TextView: setTypeface with style : 0
D/TextView: setTypeface with style : 0
D/TextView: setTypeface with style : 0
D/TextView: setTypeface with style : 0
D/TextView: setTypeface with style : 0
D/TextView: setTypeface with style : 0
D/TextView: setTypeface with style : 0
D/TextView: setTypeface with style : 0
D/TextView: setTypeface with style : 0
D/ViewRootImpl: ViewPostImeInputStage ACTION_DOWN
D/ViewRootImpl: ViewPostImeInputStage ACTION_DOWN
D/TextView: setTypeface with style : 0
            setTypeface with style : 0
D/TextView: setTypeface with style : 0
            setTypeface with style : 0
D/TextView: setTypeface with style : 0
D/ViewRootImpl: ViewPostImeInputStage ACTION_DOWN
D/ViewRootImpl: ViewPostImeInputStage ACTION_DOWN
D/TextView: setTypeface with style : 0
D/TextView: setTypeface with style : 0
D/TextView: setTypeface with style : 0
D/ViewRootImpl: ViewPostImeInputStage ACTION_DOWN
D/ViewRootImpl: ViewPostImeInputStage ACTION_DOWN
D/TextView: setTypeface with style : 0
D/TextView: setTypeface with style : 0
D/TextView: setTypeface with style : 0
D/TextView: setTypeface with style : 0
D/ViewRootImpl: ViewPostImeInputStage ACTION_DOWN
D/ViewRootImpl: ViewPostImeInputStage ACTION_DOWN
D/TextView: setTypeface with style : 0
            setTypeface with style : 0
D/TextView: setTypeface with style : 0
            setTypeface with style : 0
D/TextView: setTypeface with style : 0
D/ViewRootImpl: ViewPostImeInputStage ACTION_DOWN
D/ViewRootImpl: ViewPostImeInputStage ACTION_DOWN
D/TextView: setTypeface with style : 0
            setTypeface with style : 0
D/TextView: setTypeface with style : 0
D/TextView: setTypeface with style : 0
D/ViewRootImpl: ViewPostImeInputStage ACTION_DOWN
V/FA: Recording user engagement, ms: 631709
      Connecting to remote service
V/FA: Activity paused, time: 29816396
D/FA: Logging event (FE): user_engagement(_e), Bundle[{firebase_event_origin(_o)=auto, engagement_time_msec(_et)=631709, firebase_screen_class(_sc)=NavigationActivity, firebase_screen_id(_si)=3523377130946130508}]
V/ActivityThread: updateVisibility : ActivityRecord{56ff72a [email protected] {com.example.gonzalo.proyecto_android_2018/com.example.gonzalo.proyecto_android_2018.activities.NavigationActivity}} show : true
V/FA: Connection attempt already in progress
D/FA: Connected to remote service
V/FA: Processing queued up service tasks: 2
V/FA: Inactivity, disconnecting from the service
    
asked by Gian Franco Alexis Poma Vidal 12.11.2018 в 01:05
source

0 answers