2016-01-05 4 views
0

У меня проблема с привязкой данных в android. Выше XML-файл и класс активности:DataBinding: не удается найти класс символов

activity_main.xml (связывание в андроида: включено = "@ {loginInfo.existingUser}")

<layout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    xmlns:app="http://schemas.android.com/apk/res-auto"> 

    <data> 
    <variable 
    name="loginInfo" 
    type="com.example.android.loginapplication.LoginInfo"/> 
    </data> 

<LinearLayout 
android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" 
    android:padding="16dp"> 

    <RadioGroup 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical"> 

     <RadioButton 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="@string/new_customer" 
      android:enabled="@{loginInfo.existingUser}"/> 

     <RadioButton 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="@string/i_have_a_password"/> 
    </RadioGroup> 

    <EditText 
    android:id="@+id/password" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:inputType="textPassword"/> 
    </LinearLayout> 

    </layout> 

LoginInfoActivity.java

public class LoginInfoActivity extends AppCompatActivity { 

private LoginInfo loginInfo; 
@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    LoginInfoBinding binding = DataBindingUtil.setContentView(
      this, R.layout.activity_main); 


    binding.setLoginInfo(loginInfo); 
} 
} 

не найден сгенерированный класс LoginInfoBinding в LoginInfoActivity ...

- это правильный xml? Или это зависит от других вещей?

ответ

2

Класс привязки по умолчанию называется ресурсом компоновки. Ресурс компоновки - activity_main.xml, поэтому привязка ActivityMainBinding.

+0

спасибо! оно работает – user3195053