Ex. 'git' and 'rm'
// if you are in an activity | |
LayoutInflater inflater = getLayoutInflater(); | |
// If you have the context | |
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); | |
// or in a cleaner way, from() uses system service interally so its the same inflater | |
LayoutInflater inflater = LayoutInflater.from(context); | |
// inflating a view | |
// if you need to attach the inflated to rootView, returned view will be rootView. | |
// 3rd parameter is attach_to_root |
// https://stackoverflow.com/questions/10696986/how-to-set-the-part-of-the-text-view-is-clickable | |
SpannableString ss = new SpannableString("Android is a Software stack"); | |
ClickableSpan clickableSpan = new ClickableSpan() { | |
@Override | |
public void onClick(View textView) { | |
startActivity(new Intent(MyActivity.this, NextActivity.class)); | |
} | |
}; | |
// 0 is the start index and 7 is the end index | |
ss.setSpan(clickableSpan, 0, 7, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); |
-
The following line is bold
Hi, I am Bold (**Hi, I am Bold**) -
The following line is given emphasis
I am cooool. (*I am cooool.*) -
To write something on the new line, give two spaces and hit enter
Yay! we are on the next line -
Now comes the Headline
Since each Activity is made to work in different purpose. Some is designed to work separately with each Intent sent for example an Activity for email composing in email client. While some is designed to work as a singleton for example an email's inbox Activity. That's why it does matter to specify whether Activity is needed to be created a new one or to use the existed one. launchMode
is designed for this specifically.
launchMode can be assigned directly as an attribute tag
<activity
android:name=".SingleTaskActivity"
android:label="singleTask launchMode"
android:launchMode="singleTask">
A ViewPager
is a ViewGroup
that allows the user to flip left and right through pages of data. You supply an implementation of a PagerAdapter
to generate the pages that the view shows.
Create a custom Pager Adapter
// override 4 methods as shown below
class MyPagerAdapter: PagerAdapter() {
override fun instantiateItem(container: ViewGroup, position: Int): Any {
[Deprecated] migrated to notion
Open or create a file called gradle.properties in .gradle
directory. Inside the file, add following
org.gradle.parallel=true
: Allow you to build multiple modules in the same project at the same timeorg.gradle.daemon=true
will turn on daemon so that every time we build the application, it doesn’t need to rerun the entire Gradle application every time.
- Having setters violates open/close principle, prevents information hiding (breaks encapsulation)
- Discussing getter/setters vs public fields often obscures bigger problems with objects manipulating each others' internal state in an intimate manner and hence being too closely coupled. The idea is to make methods do what your business logic wants it to do, rather than have setters which change things at a field level.
- One way to avoid writing setters is a task based approach to the model. Think of every task that is performed in an application and add a method that changes all the affected fields at once, to perform this task.
Ref:
What are companion objects in Kotlin?