{% setvar book_path %}/reference/kotlin/dokkatest/_book.yaml{% endsetvar %} {% include "_shared/_reference-head-tags.html" %}
TopLevelClass.InnerInterface |
inner interface docs |
TopLevelInterface |
inner class docs |
TopLevelClass |
top-level class docs |
TopLevelClass.InnerClass |
inner class docs |
Unit |
top-level non-extension function docs |
String? |
top-level non-extension property docs |
fun topLevelFunction(): Unit
top-level non-extension function docs
import androidx.notARealLibrary.Thingy1 class CustomPainter() { val size: Pair<Float, Float> get() = Pair(300.0f, 300.0f) override fun toString(): String { return "ahahahaha" } val weAreUsingThingy1 = Thingy1() }
fun List<String>.topLevelExtensionFunction(): Pair<Float, Float>
top-level extension function docs
import androidx.notARealLibrary.Thingy1 class CustomPainter() { val size: Pair<Float, Float> get() = Pair(300.0f, 300.0f) override fun toString(): String { return "ahahahaha" } val weAreUsingThingy1 = Thingy1() }
and this is an XML sample from Kotlin source: {@sample frameworks/support/samples/Support4Demos/src/main/res/layout/fragment_arguments_support.xml from_attributes}
val topLevelProperty: String?
top-level non-extension property docs
import androidx.notARealLibrary.Thingy1 class CustomPainter() { val size: Pair<Float, Float> get() = Pair(300.0f, 300.0f) override fun toString(): String { return "ahahahaha" } val weAreUsingThingy1 = Thingy1() }
and this is a Java sample from Kotlin source using Kotlin syntax (does not work):
dokkatest.sampleAnnotation.samples.FragmentArgumentsSupport.onCreate
and this is a Java sample from Kotlin source using Java syntax:
public static class MyFragment extends Fragment { CharSequence mLabel; /** * Create a new instance of MyFragment that will be initialized * with the given arguments. */ static MyFragment newInstance(CharSequence label) { MyFragment f = new MyFragment(); Bundle b = new Bundle(); b.putCharSequence("label", label); f.setArguments(b); return f; } /** * Parse attributes during inflation from a view hierarchy into the * arguments we handle. */ @Override public void onInflate(@NonNull Context context, @NonNull AttributeSet attrs, @Nullable Bundle savedInstanceState) { super.onInflate(context, attrs, savedInstanceState); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.FragmentArguments); mLabel = a.getText(R.styleable.FragmentArguments_android_label); a.recycle(); } /** * During creation, if arguments have been supplied to the fragment * then parse those out. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Bundle args = getArguments(); if (args != null) { CharSequence label = args.getCharSequence("label"); if (label != null) { mLabel = label; } } } /** * Create the view for this fragment, using the arguments given to it. */ @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.hello_world, container, false); View tv = v.findViewById(R.id.text); ((TextView)tv).setText(mLabel != null ? mLabel : "(no label)"); ViewCompat.setBackground( tv, ContextCompat.getDrawable(getContext(), android.R.drawable.gallery_thumb)); return v; } }
val List<String>.topLevelExtensionProperty: Pair<Float, Float>
top-level extension property docs
import androidx.notARealLibrary.Thingy1 class CustomPainter() { val size: Pair<Float, Float> get() = Pair(300.0f, 300.0f) override fun toString(): String { return "ahahahaha" } val weAreUsingThingy1 = Thingy1() }
and after some text, we have another sample
import androidx.anotherFakeLibrary.FooFooFoo val weAreUsingFooFooFoo by lazy { FooFooFoo() }