OneEditTextActivitySelected.java revision 15a4d2ffd04dc6c70f2cd17dae12ac6bc14c69ab
1/*
2 * Copyright (C) 2009 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.imftest.samples;
18
19import android.app.Activity;
20import android.os.Bundle;
21import android.view.KeyEvent;
22import android.view.View;
23import android.view.ViewGroup;
24import android.view.WindowManager;
25import android.widget.LinearLayout;
26import android.view.inputmethod.InputMethodManager;
27import android.widget.EditText;
28import android.widget.Button;
29import android.widget.TextView;
30import android.widget.ScrollView;
31
32import com.android.internal.R;
33
34/*
35 * Activity with EditText selected initially
36 */
37public class OneEditTextActivitySelected extends Activity
38{
39    private View mRootView;
40    private View mDefaultFocusedView;
41
42    @Override
43    public void onCreate(Bundle savedInstanceState)
44    {
45        super.onCreate(savedInstanceState);
46
47        LinearLayout layout = new LinearLayout(this);
48        layout.setOrientation(LinearLayout.VERTICAL);
49        mRootView = new ScrollView(this);
50
51        EditText editText = new EditText(this);
52        editText.requestFocus();
53        mDefaultFocusedView = editText;
54        layout.addView(editText);
55
56        ((ScrollView) mRootView).addView(layout);
57        setContentView(mRootView);
58    }
59
60    public View getRootView() {
61        return mRootView;
62    }
63
64    public View getDefaultFocusedView() {
65        return mDefaultFocusedView;
66    }
67}
68