运行我的应用程序时,我的手机键盘发疯了

时间:2019-03-26 16:11:47

标签: android

我制作了一个带有textviews和每个textview的注释的应用程序,因此我使用自定义数组适配器将其作为listview进行布局,布局是关于textview和其旁边的note字段(edittext)的,这是当我在edittext上移动我的手机时遇到的问题键盘发疯了,我无法输入任何字母

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/listView"


    >

    <TextView
        android:layout_width="wrap_content"
        android:layout_marginRight="60dp"
        android:layout_marginTop="16dp"
        android:layout_marginLeft="10dp"
        android:layout_height="wrap_content"
        android:id="@+id/main_text"
        android:text="discreption"/>

    <EditText
        android:id="@+id/editText"
        android:layout_width="wrap_content"
        android:layout_height="100dp"
        android:layout_alignParentRight="true"
        android:layout_toRightOf="@+id/main_text"
        android:hint="Add"
        android:inputType="text"
         />


</RelativeLayout>

(这是arrayadapter)

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;


import com.example.myapplication.R;
import com.example.myapplication.Word;

import java.util.ArrayList;

/**
 * Created by khadijah on 3/13/2018.
 */

public class WordAdapter extends ArrayAdapter<Word> {

    public WordAdapter(Activity context, ArrayList<Word> words) {
        // Here, we initialize the ArrayAdapter's internal storage for the context and the list.
        // the second argument is used when the ArrayAdapter is populating a single TextView.
        // Because this is a custom adapter for two TextViews and an ImageView, the adapter is not
        // going to use this second argument, so it can be any value. Here, we used 0.
        super(context, 0, words);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        // Check if the existing view is being reused, otherwise inflate the view
        View listItemView = convertView;
        if (listItemView == null) {
            listItemView = LayoutInflater.from(getContext()).inflate(
                    R.layout.list_item, parent, false);
        }

        // Get the Book object located at this position in the list
        Word currentWord = getItem(position);

        // Find the TextView in the list_item.xml layout with the ID book_name
        TextView discrepionTextView = (TextView) listItemView.findViewById(R.id.main_text);

        // Get the Book name from the current Book object and
        // set this text on the TextView
        discrepionTextView.setText(currentWord.getDiscription());

        TextView editTextView = (TextView)listItemView.findViewById(R.id.editText);
        editTextView.setText(currentWord.getEditText());
        return listItemView;

    }
}

(这是主要活动)

public class MainActivity extends AppCompatActivity {
    private ArrayList<Word> words = new ArrayList<Word>();

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

        words.add(new Word("Complain",""));
        words.add(new Word("Present Hitstory",""));
        words.add(new Word("Past History",""));
        words.add(new Word("Family History",""));
        words.add(new Word("Examination",""));
        words.add(new Word("Investigation",""));
        words.add(new Word("Treatment",""));
        words.add(new Word("Prov-Diagnoses",""));
        words.add(new Word("D.D",""));
        words.add(new Word("Medication",""));


        WordAdapter items = new WordAdapter(this, words);
        ListView list = (ListView) findViewById(R.id.listView);
        list.setAdapter(items);

    }
}

0 个答案:

没有答案