Skip to content

Commit 508f597

Browse files
author
fengjian
committed
add sample code for KeyBoradLess
1 parent f5c182c commit 508f597

File tree

2 files changed

+54
-9
lines changed

2 files changed

+54
-9
lines changed

app/src/main/java/com/jayfeng/lesscode/app/activity/KeyboradActivity.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,42 @@
22

33
import android.app.Activity;
44
import android.os.Bundle;
5+
import android.view.View;
6+
import android.widget.Button;
7+
import android.widget.EditText;
58

69
import com.jayfeng.lesscode.app.R;
10+
import com.jayfeng.lesscode.core.KeyBoardLess;
11+
import com.jayfeng.lesscode.core.ViewLess;
712

813
public class KeyboradActivity extends Activity {
914

15+
private EditText editText;
16+
private Button showKeyboradButton;
17+
private Button hideKeyboradButton;
18+
1019
@Override
1120
protected void onCreate(Bundle savedInstanceState) {
1221
super.onCreate(savedInstanceState);
1322
setContentView(R.layout.activity_keyborad);
23+
24+
editText = ViewLess.$(this, R.id.edit);
25+
showKeyboradButton = ViewLess.$(this, R.id.show);
26+
hideKeyboradButton = ViewLess.$(this, R.id.hide);
27+
28+
showKeyboradButton.setOnClickListener(new View.OnClickListener() {
29+
@Override
30+
public void onClick(View v) {
31+
KeyBoardLess.$show(KeyboradActivity.this, editText);
32+
}
33+
});
34+
35+
hideKeyboradButton.setOnClickListener(new View.OnClickListener() {
36+
@Override
37+
public void onClick(View v) {
38+
KeyBoardLess.$hide(KeyboradActivity.this, editText);
39+
}
40+
});
41+
1442
}
1543
}
Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,29 @@
1-
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
2-
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
3-
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
4-
android:paddingRight="@dimen/activity_horizontal_margin"
5-
android:paddingTop="@dimen/activity_vertical_margin"
6-
android:paddingBottom="@dimen/activity_vertical_margin"
1+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
2+
xmlns:tools="http://schemas.android.com/tools"
3+
android:layout_width="match_parent"
4+
android:layout_height="match_parent"
5+
android:orientation="vertical"
76
tools:context="com.jayfeng.lesscode.app.activity.KeyboradActivity">
87

9-
<TextView android:text="@string/hello_world" android:layout_width="wrap_content"
10-
android:layout_height="wrap_content" />
8+
<EditText android:id="@+id/edit"
9+
android:layout_width="100dp"
10+
android:layout_height="wrap_content"
11+
android:layout_gravity="center_horizontal"
12+
android:layout_marginTop="40dp"/>
1113

12-
</RelativeLayout>
14+
<Button
15+
android:id="@+id/show"
16+
android:layout_width="wrap_content"
17+
android:layout_height="wrap_content"
18+
android:layout_gravity="center_horizontal"
19+
android:layout_margin="40dp"
20+
android:text="Show KeyBorad" />
21+
22+
<Button
23+
android:id="@+id/hide"
24+
android:layout_width="wrap_content"
25+
android:layout_height="wrap_content"
26+
android:layout_gravity="center_horizontal"
27+
android:text="Hide KeyBorad" />
28+
29+
</LinearLayout>

0 commit comments

Comments
 (0)