升级匕首柄后(版本:2.31-alpha
)ApplicationComponent.class
无法找到。Component
类似 RoomDatabase的替代方案是什么?
@Module
@InstallIn(ApplicationComponent::class)
class RoomModule() {
private val DATABASE_NAME = "salat_time"
@Singleton
@Provides
fun provideRoomDatabase(@ApplicationContext appContext: Context) = Room.databaseBuilder(
appContext,
AppDatabase::class.java,
DATABASE_NAME
).createFromAsset("db/$DATABASE_NAME.sqlite").build()
@Singleton
@Provides
fun provideLocalSalatRepository(database: AppDatabase) = LocalSalatRepository(database)
@Singleton
@Provides
fun provideDistrictRepository(database: AppDatabase) = DistrictRepository(database)
}
Run Code Online (Sandbox Code Playgroud) 我如何添加一个事件OnTouchListener
,并OnclickListener
在一段时间LinearLayout
?
这是我的代码,但不起作用
final LinearLayout llTimeTable=(LinearLayout) findViewById(R.id.llSehriIftar);
llTimeTable.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(MainActivity.this, Ramadandate.class);
startActivity(intent);
}
});
llTimeTable.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
llTimeTable.setBackgroundColor(Color.rgb(51, 51, 255));
break;
case MotionEvent.ACTION_UP:
// set color back to default
llTimeTable.setBackgroundColor(Color.rgb(76, 106, 225));
break;
}
return true;
}
});
Run Code Online (Sandbox Code Playgroud)
但是,当我只使用OnclickListener
它工作时,当我只使用它的onTouch
方法时,它可以工作,但两者同时不起作用.