Skip to content

Commit c8bb6ca

Browse files
authored
Add kotlin version of code (#1290)
1 parent c7d8d86 commit c8bb6ca

File tree

2 files changed

+52
-22
lines changed

2 files changed

+52
-22
lines changed

versioned_docs/version-6.x/getting-started.md

+26-11
Original file line numberDiff line numberDiff line change
@@ -70,20 +70,35 @@ npx pod-install ios
7070
```
7171

7272
`react-native-screens` package requires one additional configuration step to properly
73-
work on Android devices. Edit `MainActivity.java` file which is located in `android/app/src/main/java/<your package name>/MainActivity.java`.
73+
work on Android devices. Edit `MainActivity.kt` or `MainActivity.java` file which is located under `android/app/src/main/java/<your package name>/`.
7474

7575
Add the highlighted code to the body of `MainActivity` class:
7676

77-
```java {3-6}
78-
public class MainActivity extends ReactActivity {
79-
// ...
80-
@Override
81-
protected void onCreate(Bundle savedInstanceState) {
82-
super.onCreate(null);
83-
}
84-
// ...
85-
}
86-
```
77+
<Tabs>
78+
<TabItem value='kotlin' label='Kotlin' default>
79+
```kotlin {3-5}
80+
class MainActivity: ReactActivity() {
81+
// ...
82+
override fun onCreate(savedInstanceState: Bundle?) {
83+
super.onCreate(null)
84+
}
85+
// ...
86+
}
87+
```
88+
</TabItem>
89+
<TabItem value='java' label='Java'>
90+
```java {3-6}
91+
public class MainActivity extends ReactActivity {
92+
// ...
93+
@Override
94+
protected void onCreate(Bundle savedInstanceState) {
95+
super.onCreate(null);
96+
}
97+
// ...
98+
}
99+
```
100+
</TabItem>
101+
</Tabs>
87102

88103
and make sure to add the following import statement at the top of this file below your package statement:
89104

versioned_docs/version-7.x/getting-started.md

+26-11
Original file line numberDiff line numberDiff line change
@@ -70,20 +70,35 @@ npx pod-install ios
7070
```
7171

7272
`react-native-screens` package requires one additional configuration step to properly
73-
work on Android devices. Edit `MainActivity.java` file which is located in `android/app/src/main/java/<your package name>/MainActivity.java`.
73+
work on Android devices. Edit `MainActivity.kt` or `MainActivity.java` file which is located under `android/app/src/main/java/<your package name>/`.
7474

7575
Add the highlighted code to the body of `MainActivity` class:
7676

77-
```java {3-6}
78-
public class MainActivity extends ReactActivity {
79-
// ...
80-
@Override
81-
protected void onCreate(Bundle savedInstanceState) {
82-
super.onCreate(null);
83-
}
84-
// ...
85-
}
86-
```
77+
<Tabs>
78+
<TabItem value='kotlin' label='Kotlin' default>
79+
```kotlin {3-5}
80+
class MainActivity: ReactActivity() {
81+
// ...
82+
override fun onCreate(savedInstanceState: Bundle?) {
83+
super.onCreate(null)
84+
}
85+
// ...
86+
}
87+
```
88+
</TabItem>
89+
<TabItem value='java' label='Java'>
90+
```java {3-6}
91+
public class MainActivity extends ReactActivity {
92+
// ...
93+
@Override
94+
protected void onCreate(Bundle savedInstanceState) {
95+
super.onCreate(null);
96+
}
97+
// ...
98+
}
99+
```
100+
</TabItem>
101+
</Tabs>
87102

88103
and make sure to add the following import statement at the top of this file below your package statement:
89104

0 commit comments

Comments
 (0)