我正在我的项目中实施dagger 2.为此,我写了下面的代码行:
@Inject
VideoControllerView mediaController;
@Module
public class PlayerModule {
@Provides
VideoControllerView providesVideoControllerView(Context context, VideoControllerView.Controlers cntrls) {
return new VideoControllerView(context, cntrls);
}
}
@Component(modules = PlayerModule.class)
public interface PlayerComponent {
VideoControllerView getVideoControllerView();
}
Run Code Online (Sandbox Code Playgroud)
但是当我试图编译我的应用程序时,我得到的错误是:
Error:(14, 25) error: android.content.Context cannot be provided without an @Provides-annotated method.
android.content.Context is injected at
com.multitv.multitvplayersdk.module.PlayerModule.providesVideoControllerView(context, …)
com.multitv.multitvplayersdk.controls.VideoControllerView is provided at
com.multitv.multitvplayersdk.component.PlayerComponent.getVideoControllerView()
Run Code Online (Sandbox Code Playgroud)
我已经四处查看如何解决这个问题,但无济于事.请帮我.
我制作了 4 个单选按钮,并希望在单击其中任何一个按钮时保存状态,然后希望在应用程序中使用该保存状态。我该怎么做?
myOption1.setChecked(true);
myOption2.setChecked(true);
myOption3.setChecked(true);
myOption4.setChecked(true);
Run Code Online (Sandbox Code Playgroud) 我已经使用four单选按钮创建了一个应用程序.问题是最后一个单选按钮最初是不可点击的,直到你点击其他按钮.点击其他单选按钮后,最后一个单选按钮变为clickable.plz告诉我如何解决这个问题.提前致谢.
private void uncheckAllOptions()
{
myOption1.setChecked(true);
myOption2.setChecked(true);
myOption3.setChecked(true);
myOption4.setChecked(true);
myOption1.setChecked(false);
myOption2.setChecked(false);
myOption3.setChecked(false);
myOption4.setChecked(false);
}
Run Code Online (Sandbox Code Playgroud)
我正在使用此代码保存单选按钮的状态,但最后一个单选按钮始终保持不可点亮状态,除非单击前3个单选按钮之一
我希望在我的应用程序中包含另一个布局的布局.但我无法在tag的帮助下完成它.它显示错误消息,您必须在include标记中指定布局:.这是两个xml文件:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<include
android:id="@layout/linearlayout"
/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
这是第二个:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/linearlayout"
android:orientation="vertical"
android:background="@color/LabelColorLight"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<naseeb.bar.DashboardLayout
android:id="@+id/dashboard"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1">
<Button
android:id="@+id/myprofile"
style="@style/HomeButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableTop="@drawable/ic_home_myprofile"
android:text="@string/home_myprofile" />
<Button
android:id="@+id/beermail"
style="@style/HomeButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableTop="@drawable/ic_home_beermail"
android:text="@string/home_beermail" />
<Button
android:id="@+id/beerstyles"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/HomeButton"
android:text="@string/home_beerstyles"
android:drawableTop="@drawable/ic_home_styles" />
<Button
android:id="@+id/offlineratings"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/HomeButton"
android:text="@string/home_offlineratings"
android:drawableTop="@drawable/ic_home_offline" />
<Button
android:id="@+id/places"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/HomeButton"
android:text="@string/home_places"
android:drawableTop="@drawable/ic_home_places" />
<Button
android:id="@+id/top50"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/HomeButton"
android:text="@string/home_top50"
android:drawableTop="@drawable/ic_home_top50" />
<Button …Run Code Online (Sandbox Code Playgroud) 我在我的应用程序中使用广告.当模拟器在纵向模式下工作时工作正常但是当我将模拟器转换为横向模式时,即使我已经给出了android:layout_width ="match_parent",它也会填充水平屏幕.请告诉我如何解决这个问题.
这是xml文件:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:id="@+id/rl"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="@string/hello_world"
/>
<com.google.ads.AdView
android:id="@+id/ad"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
ads:adSize="BANNER"
ads:adUnitId="a1501e5633125fb"
ads:loadAdOnCreate="true"
ads:testDevices="TEST_EMULATOR, 123456789ABCDEF" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud) 我正在制作网格布局并希望将其放在警告对话框中,但是当我尝试使用时显示警告对话框时show(),应用程序会显示异常.
这是代码:
public class GridViewActivity extends Activity {
GridView gridView;
Context context;
static final String[] MOBILE_OS = new String[] { "timer", "about"};
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
gridView = (GridView) findViewById(R.id.gridView1);
gridView.setAdapter(new ImageAdapter(this, MOBILE_OS));
gridView.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View v,
int position, long id) {
// Toast.makeText(
// getApplicationContext(),
// ((TextView) v.findViewById(R.id.grid_item_label))
// .getText(), Toast.LENGTH_SHORT).show();
if(position == 0){
Toast.makeText(GridViewActivity.this, "first icon is pressed", Toast.LENGTH_SHORT).show();
}
else if(position == 1){
Toast.makeText(GridViewActivity.this, "second icon …Run Code Online (Sandbox Code Playgroud)