OctaviaMelody
@OctaviaMelody
Люблю играть на виолончели

Как открывать текстовые документы в моем приложении?

Еще раз приветствую.
Вопрос простой. Как я могу открывать текстовые документы с файлового менеджера в EditText своего приложения?
Вот так, как здесь.
Вот мой MainActivity:
import android.app.Activity;
        import android.graphics.Color;
        import android.os.Bundle;
        import android.support.v7.app.ActionBarActivity;
        import android.text.Editable;
        import android.text.TextWatcher;
        import android.widget.Button;
        import android.widget.EditText;
        import android.widget.TextView;

public class MainActivity extends ActionBarActivity {

    //Widget GUI
    EditText txtStatus;
    TextView lblCount;
    Button btnTweet;

    // Init Static Members
    static int MIN_COUNT = 0;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        // Init Widget GUI
        txtStatus = (EditText)findViewById(R.id.txtStatus);
        lblCount = (TextView)findViewById(R.id.lblCount);

        // Attached Listener to Edit Text Widget
        txtStatus.addTextChangedListener(new TextWatcher() {

            public void onTextChanged(CharSequence s, int start, int before, int count) {
                // TODO Auto-generated method stub

            }

            public void beforeTextChanged(CharSequence s, int start, int count,
                                          int after) {
                // TODO Auto-generated method stub

            }

            public void afterTextChanged(Editable s) {

                // Display Remaining Character with respective color
                int count = MIN_COUNT + s.length();
                lblCount.setText(Integer.toString(count));
                if(count < 0);
            }
        });

    }


Activity_main.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="fill_parent"
    android:layout_height="fill_parent" android:background="#fff">

    <LinearLayout android:id="@+id/linearLayout1"
        android:layout_width="match_parent" android:layout_height="wrap_content"
        android:touchscreenBlocksFocus="false">


        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:text="Кількість символів:"
            android:id="@+id/textView" />

        <TextView android:id="@+id/lblCount" android:text="0"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:layout_gravity="right" android:layout_width="wrap_content"
            android:paddingRight="10dp"
            android:layout_weight="1" android:layout_height="match_parent"
            android:gravity="right|center" ></TextView>
    </LinearLayout>

    <EditText android:layout_width="match_parent"
        android:layout_height="match_parent" android:layout_weight="0"
        android:id="@+id/txtStatus">
        <requestFocus></requestFocus>
    </EditText>

</LinearLayout>

Большое спасибо заранее!
  • Вопрос задан
  • 115 просмотров
Решения вопроса 1
@onepavel
Консультация и разработка мобильных приложений
Комментировать
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы