Android 2.3: элементы страницы не кликабельны - PullRequest
1 голос
/ 14 марта 2011

Привет всем. Я довольно новичок в программировании для Android (2 месяца), поэтому я надеюсь, что вы простите мой глупый вопрос, который сводил меня с ума на несколько часов. Я разработал приложение, имеющее в качестве первой страницы следующую форму входа:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:scrollbars="vertical" android:scrollbarStyle="insideOverlay" android:layout_height="fill_parent" android:scrollbarAlwaysDrawVerticalTrack="true" android:gravity="top" android:id="@+id/LinearLayoutConnect" android:paddingTop="0px" android:paddingLeft="20px" android:paddingRight="10px" android:paddingBottom="20px">
    <ScrollView android:layout_width="fill_parent" android:layout_height="fill_parent" android:scrollbarSize="10px" android:scrollbarStyle="insideOverlay" android:addStatesFromChildren="true" android:id="@+id/ScrollView03">
        <LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" android:id="@+id/LinearLayout02">
            <LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" android:id="@+id/connect" android:paddingTop="25px">
                <LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="horizontal">
                    <TextView android:layout_width="0dip" android:layout_height="wrap_content" android:text="@string/connect.envCode" android:id="@+id/label_env" android:textColor="#fff" android:layout_weight="33"></TextView>
                    <EditText android:layout_width="0dip" android:layout_height="wrap_content" android:id="@+id/env" android:layout_weight="67"></EditText> 
                </LinearLayout>

                <LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="horizontal" android:paddingTop="15px">
                    <TextView android:layout_width="0dip" android:layout_height="wrap_content" android:text="@string/connect.email" android:id="@+id/label_login" android:textColor="#fff" android:layout_weight="33"></TextView>
                    <EditText android:layout_width="0dip" android:layout_height="wrap_content" android:id="@+id/login" android:layout_weight="67"></EditText>
                </LinearLayout>

                <LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="horizontal" android:paddingTop="15px">
                    <TextView android:layout_width="0dip" android:layout_height="wrap_content" android:text="@string/connect.password" android:id="@+id/label_password" android:textColor="#fff" android:layout_weight="33"></TextView>
                    <EditText android:layout_width="0dip" android:layout_height="wrap_content" android:id="@+id/password" android:password="true" android:layout_weight="67"></EditText>
                </LinearLayout>

                <CheckBox android:layout_width="wrap_content" android:layout_height="wrap_content" android:enabled="true" android:text="@string/connect.remember" android:id="@+id/che_user_save" android:layout_gravity="center" android:paddingTop="20px"></CheckBox>

                <TableLayout android:id="@+id/TableLayoutconnect" android:layout_height="wrap_content" android:visibility="visible" android:layout_width="fill_parent" android:paddingTop="20px">
                    <TableRow android:id="@+id/TableRowconnect01" android:layout_height="wrap_content" android:layout_width="fill_parent">
                        <Button android:layout_width="0dip" android:layout_height="wrap_content" android:text="@string/connect.connect" android:id="@+id/auth_button_connect" android:layout_weight="52"></Button>
                        <Button android:layout_width="0dip" android:layout_height="wrap_content" android:text="@string/global.reset" android:id="@+id/auth_button_reset" android:layout_weight="48"></Button>
                    </TableRow>
                </TableLayout>

                <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/connect.link" android:width="266sp" android:gravity="center" android:layout_marginTop="20sp" android:padding="4sp" android:background="#fe0000" android:textColor="#ffffff" android:id="@+id/PromoBar" ></TextView>
            </LinearLayout>

            <LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" android:id="@+id/disconnect">
                <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/global.disconnect" android:id="@+id/auth_button_disconnect" android:layout_weight="60"></Button>
            </LinearLayout>
        </LinearLayout>
    </ScrollView>
</LinearLayout>

Это связанный код Java:

env = (EditText) findViewById(R.id.env);
txt_login = (EditText) findViewById(R.id.login);
txt_password = (EditText) findViewById(R.id.password);

but_connect = (Button) findViewById(R.id.auth_button_connect);
but_connect.setOnClickListener(new OnClickListener(){
    public void onClick(View v) {
        XMLRPC_connect();
    }
});

but_reset = (Button) findViewById(R.id.auth_button_reset);
but_reset.setOnClickListener(new OnClickListener(){
    public void onClick(View v) {
    try {
            ClearSettings(getBaseContext(),filename_settings);
            env.setText("");
                txt_login.setText("");
                txt_password.setText("");
        } catch(Exception e) {}
    }
});

Вопрос в следующем: В предыдущих версиях Android (до 2.2) все кнопки и поля EditText прекрасно нажимались и редактировались.
В Android 2.3 (с использованием эмулятора под Eclipse - у вас нет реального устройства) экран абсолютно нечувствителен к касанию или щелчку: ни один элемент на нем не может быть выделен и выделен, это можно сделать только с помощью трекбола или клавиатуры , в результате чего довольно раздражает. Сам экран не прокручивается.
Я пытался заставить все поля TextEdit и кнопки редактировать, фокусировать или нажимать, я пытался обновить Eclipse ADT, я пытался скомпилировать проект с библиотеками Android 2.3, ... безрезультатно. Какой бы элемент я ни щелкнул, его функция onClick никогда не срабатывает ... У меня действительно закончились решения! Спасибо за вашу помощь!

1 Ответ

1 голос
/ 17 марта 2011

У меня есть три совета:

  1. Я думаю, вы можете избавиться от LinearLayout с идентификатором connect и disconnect, они оба вертикальные и встроены в вертикальный LinearLayout с идентификатором LinearLayout02.Результат должен быть таким же.
  2. Переопределите onTouchEvent в упражнении и проверьте, вызывается ли это при касании экрана.С этого момента шаг за шагом углубляйтесь в макет.
  3. Попробуйте удалить один вид / макет за раз.Может быть, вы найдете причину таким образом ...
...