Skip to content

Commit

Permalink
add sample code for KeyBoradLess
Browse files Browse the repository at this point in the history
  • Loading branch information
fengjian committed Apr 1, 2016
1 parent f5c182c commit 508f597
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,42 @@

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

import com.jayfeng.lesscode.app.R;
import com.jayfeng.lesscode.core.KeyBoardLess;
import com.jayfeng.lesscode.core.ViewLess;

public class KeyboradActivity extends Activity {

private EditText editText;
private Button showKeyboradButton;
private Button hideKeyboradButton;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_keyborad);

editText = ViewLess.$(this, R.id.edit);
showKeyboradButton = ViewLess.$(this, R.id.show);
hideKeyboradButton = ViewLess.$(this, R.id.hide);

showKeyboradButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
KeyBoardLess.$show(KeyboradActivity.this, editText);
}
});

hideKeyboradButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
KeyBoardLess.$hide(KeyboradActivity.this, editText);
}
});

}
}
35 changes: 26 additions & 9 deletions app/src/main/res/layout/activity_keyborad.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,29 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.jayfeng.lesscode.app.activity.KeyboradActivity">

<TextView android:text="@string/hello_world" android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<EditText android:id="@+id/edit"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="40dp"/>

</RelativeLayout>
<Button
android:id="@+id/show"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_margin="40dp"
android:text="Show KeyBorad" />

<Button
android:id="@+id/hide"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="Hide KeyBorad" />

</LinearLayout>

0 comments on commit 508f597

Please sign in to comment.