0

My question is about Android/Java.

How can I call my custom view with a name such as

<input> 

instead of

<org.javaforum.input> 

without adding anything in the MainActivity.java?

I already read this: https://stackoverflow.com/a/17478278/16627950

But there I must add something in MainActivity.java.

I also read this: https://stackoverflow.com/a/30066376/16627950

But I don't know where do the variables mInflator and mPrefix come from.

I also read this: https://stackoverflow.com/a/13316335/16627950

But I don't know what are the programmatically steps to do so.

So how can I hook into the layout inflation in code, and handle instantiating my class for that tag myself?

1

1 Answer 1

1

mInflator and mPrefix, are custom properties declared at the top of the activity class, nothing special, in order to implement the custom layout you have to call:

val myInflater = LayoutInflater.from(this) .cloneInContext(this) myInflater.factory2 = MyLayoutInflater() 

This from your onCreate method of the activity, I think that is not possible to add a factory without tounching the activity code

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.