Типичным объявлением переменной является
extern int x;
. Поскольку это только объявление, требуется одно определение. Соответствующим определением будет:
int x;
Например, следующее генерирует ошибку:
extern int x;
int main()
{
x = 0;
}
//int x; // uncomment this line for successful definition
Аналогичные замечания относятся к функциям. Объявление функции без ее определения приводит к ошибке:
void foo(); // declaration only
int main()
{
foo();
}
//void foo() {} //uncomment this line for successful definition
Будьте осторожны, чтобы выполняемая вами функция точно соответствовала той, которую вы объявили. Например, у вас могут быть несогласованные cv-квалификаторы:
void foo(int& x);
int main()
{
int x;
foo(x);
}
void foo(const int& x) {} //different function, doesn't provide a definition
//for void foo(int& x)
Другие примеры несоответствий включают
Сообщение об ошибке из компилятора часто дает вам полное объявление переменной или функции, которая была объявлена, но не определена. Сравните его с определением, которое вы указали. Убедитесь, что каждая деталь соответствует.
Я понял. Дело в том, что вам нужно поставить EditText внутри RelativeLayout. Теперь он работает.
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/edit_text">
<EditText
android:layout_width="120dp"
android:layout_height="21dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_margin="6dp"
android:background="#00000000"
android:imeOptions="actionDone"
android:inputType="textPersonName"
android:maxLength="20"
android:maxLines="1"
android:paddingLeft="2dp"
android:textColor="#FFFFFF"/>
</RelativeLayout>
Он работал после добавления
android:scrollHorizontally="true"
android:singleLine="true"
android:gravity="right|center_vertical"
В
<EditText
android:background="@drawable/sk"
android:id="@+id/ed"
android:textSize="@dimen/sed"
android:textColor="@color/tc"
android:scrollHorizontally="true"
android:singleLine="true"
android:gravity="right|center_vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
к моему edittext
Поместите свой EditText внутри HorizontalScrollView
, и он работает.
<HorizontalScrollView
android:id="@+id/rlEmail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scrollHorizontally="true"
android:layout_alignLeft="@+id/etPhone"
android:layout_alignRight="@+id/imgBtnEdit"
android:layout_below="@+id/etPhone" >
<EditText
android:id="@+id/etEmail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:ems="10"
android:enabled="false"
android:focusable="false"
android:text="info@friedman.com"
android:maxLines="1"
android:singleLine="true"
android:scrollHorizontally="true" />
</HorizontalScrollView>
После некоторых исследований я нашел, что это работает.
Использование android:inputType="text"
внутри EditText
сработало для меня.
Надеюсь, это поможет кому-то и сэкономит ваше время :)