- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
目前,我正在做一个android项目,我在其中实现了底部导航 View 和滑动效果,我可以在其中左右交换 fragment 。它们是同步的。
不幸的是,我有 2 个错误,我无法解决。
E/MessageQueue-JNI: java.lang.IllegalStateException: Cannot execute task: the task is already running.
这是因为 Asynctask 在它已经运行时被调用了吗?
我想我必须在运行 Asynctask 之前取消它,但我该怎么做呢?
图片在这里:
* 代码在这里 *
主要 Activity :
@Override
public void onBackPressed() {
if (mPager.getCurrentItem() == 0) {
// If the user is currently looking at the first step, allow the system to handle the
// Back button. This calls finish() on this activity and pops the back stack.
super.onBackPressed();
} else {
// Otherwise, select the previous step.
mPager.setCurrentItem(mPager.getCurrentItem() - 1);
}
}
/**
* view pager.
*/
public void setupViewPager(ViewPager viewPager){
ViewPageAdapter adapter = new ViewPageAdapter(getSupportFragmentManager());
adapter.addFragment(new StartsideFragment());
adapter.addFragment(new CardViewTabelFragment());
adapter.addFragment(new SensorOversigtFragment());
adapter.addFragment(new KontaktFragment());
viewPager.setAdapter(adapter);
}
public void setViewPager(int fragmentNumber){
mPager.setCurrentItem(fragmentNumber);
}
public void enableViewPagerSwitch(){
mPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override
public void onPageSelected(int position) {
if (prevMenuItem != null) {
prevMenuItem.setChecked(false);
}
else
{
mBottomNav.getMenu().getItem(0).setChecked(false);
}
Log.d("page", "onPageSelected: "+position);
mBottomNav.getMenu().getItem(position).setChecked(true);
prevMenuItem = mBottomNav.getMenu().getItem(position);
}
@Override
public void onPageScrollStateChanged(int state) {
}
});
setupViewPager( mPager );
}
public void bot_Navigation() {
mBottomNav = (BottomNavigationView) findViewById( R.id.nav_bot );
botNavHelper.disableShiftMode( mBottomNav );
mBottomNav.setOnNavigationItemSelectedListener( new BottomNavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
switch (item.getItemId()) {
case R.id.bot_startside:
// overridePendingTransition( R.anim.slide_in_right, R.anim.slide_out_left );
//mPager.setCurrentItem( 0 );
setViewPager( 0 );
//fragment = new StartsideFragment();
break;
case R.id.bot_datatabel:
//overridePendingTransition( R.anim.slide_in_right, R.anim.slide_out_left );
//mPager.setCurrentItem( 1 );
setViewPager( 1 );
//fragment = new CardViewTabelFragment();
//viewPager.setCurrentItem( 1 );
break;
case R.id.bot_sensorOversigt:
//overridePendingTransition( R.anim.slide_in_right, R.anim.slide_out_left );
//mPager.setCurrentItem( 2 );
setViewPager( 2 );
//fragment = new KontaktFragment();
break;
case R.id.bot_kontakt:
//overridePendingTransition( R.anim.slide_in_right, R.anim.slide_out_left );
//mPager.setCurrentItem( 3 );
setViewPager( 3 );
//fragment = new SensorOversigtFragment();
break;
case R.id.bot_logUd:
//overridePendingTransition( R.anim.slide_in_right, R.anim.slide_out_left );
//mPager.setCurrentItem( 4 );
setViewPager( 4 );
alertDialog();
break;
}
if (fragment != null) {
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
ft.replace( R.id.flMain, fragment );
ft.commit();
}
return true;
}
} );
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate( savedInstanceState );
onCreate2();
bot_Navigation();
}
protected void onCreate2() {
// protected void onCreate2(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
setContentView( R.layout.activity_main );
Toolbar toolbar = (Toolbar) findViewById( R.id.toolbar );
setSupportActionBar( toolbar );
//toolbar.setLogo( R.mipmap.ic_launcher_cxweb_black );
TextView mTitle = (TextView) toolbar.findViewById( R.id.toolbartitle );
mTitle.setText( toolbar.getTitle() );
getSupportActionBar().setDisplayShowTitleEnabled( false );
//toolbar.setTitle( "LeoSenses" );
mPager = (ViewPager) findViewById( R.id.flMain );
enableViewPagerSwitch();
DrawerLayout drawer = (DrawerLayout) findViewById( R.id.drawer_layout );
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close );
drawer.addDrawerListener( toggle );
toggle.syncState();
NavigationView navigationView = (NavigationView) findViewById( R.id.nav_view );
navigationView.setNavigationItemSelectedListener( this );
//Default fragment for startside
android.support.v4.app.FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
ft.replace( R.id.flMain, new StartsideFragment() );
ft.commit();
navigationView.setCheckedItem( R.id.nav_startside );
PreferenceManager.getDefaultSharedPreferences( this ).getBoolean( "brugPosVedStart", true );
}
ViewPageAdapter:
public class ViewPageAdapter extends FragmentStatePagerAdapter {
private final List<Fragment> mFragmentList = new ArrayList<>();
public ViewPageAdapter(FragmentManager fm) {
super( fm );
}
public void addFragment(Fragment fragment) {
mFragmentList.add( fragment );
}
@Override
public Fragment getItem(int position) {
return mFragmentList.get( position );
}
@Override
public int getCount() {
return mFragmentList.size();
}
}
回收 View 适配器:
public class RecyclerAdapter extends RecyclerView.Adapter<RecyclerAdapter.RecyclerViewHolder> {
private ViewPager mPager;
@Override
public RecyclerViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
View view = LayoutInflater.from( viewGroup.getContext() ).inflate( R.layout.fragment_card_view_tabel, viewGroup, false );
viewGroup.setOnClickListener( new View.OnClickListener() {
@Override
public void onClick(View view) {
}
} );
return new RecyclerViewHolder( view );
}
@Override
public void onBindViewHolder(RecyclerViewHolder recyclerViewHolder, int i) {
recyclerViewHolder.mBeskrivelse.setText( OurData.beskrivelse[i] );
recyclerViewHolder.mTitle.setText( OurData.title[i] );
recyclerViewHolder.cardView.setCardBackgroundColor( Color.parseColor( OurData.colors[i] ) );
}
@Override
public int getItemCount() {
return OurData.title.length;
}
class RecyclerViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
public int nummer;
private TextView mBeskrivelse;
private TextView mTitle;
private CardView cardView;
public RecyclerViewHolder(View itemView) {
super( itemView );
mPager = (ViewPager) itemView.findViewById( R.id.flMain );
mBeskrivelse = (TextView) itemView.findViewById( R.id.item_beskrivelse );
mTitle = (TextView) itemView.findViewById( R.id.item_title );
cardView = (CardView) itemView.findViewById( R.id.card_view );
itemView.setOnClickListener( this );
}
@Override
public void onClick(View v) {
nummer = getAdapterPosition();
if (nummer == 0) {
//mPager.setCurrentItem(0);
((FragmentActivity) itemView.getContext()).getSupportFragmentManager().beginTransaction().replace( R.id.flMain, new DataTabelFragment() ).commit();
} else if (nummer == 1) {
((FragmentActivity) itemView.getContext()).getSupportFragmentManager().beginTransaction().replace( R.id.flMain, new Sensor1Fragment() ).commit();
} else if (nummer == 2) {
((FragmentActivity) itemView.getContext()).getSupportFragmentManager().beginTransaction().replace( R.id.flMain, new Sensor2Fragment() ).commit();
} else if (nummer == 3) {
((FragmentActivity) itemView.getContext()).getSupportFragmentManager().beginTransaction().replace( R.id.flMain, new Sensor3Fragment() ).commit();
}
}
}
}
带有异步任务的 fragment 之一:
public class DataTabelFragment extends Fragment implements jsonAsynctask.DataTabelFragment {
public TextView sensor1;
jsonAsynctask jsonasynctask = new jsonAsynctask( this );
public DataTabelFragment() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate( R.layout.fragment_data_tabel, container, false );
sensor1 = (TextView) view.findViewById( R.id.sensorAlleBox );
jsonasynctask.execute();
return view;
}
@Override
public void onJobFinishListener(List<String> allId) {
//when this method is trigered by your asynctask
//it means that you are in ui thread and update your ui component
for (int i = 0; i < allId.size(); i++) {
sensor1.append( jsonasynctask.allId.get( i ) + " | " + jsonasynctask.allDevice.get( i ) + " | " + jsonasynctask.allTemp.get( i ) + " | " + jsonasynctask.allHum.get( i ) + " | " + jsonasynctask.allBat.get( i ) + " | " + jsonasynctask.allMode.get( i ) + " | " + jsonasynctask.allLux.get( i ) + " | " + jsonasynctask.allDate_time.get( i ) + "\n\n" );
}
}
}
* 更新 *
使用 ASYNCTASK 发生错误的 fragment :
public class SensorOversigtFragment extends Fragment implements jsonAsynctask.DataTabelFragment {
private TextView firstValue;
private TextView firstValue2;
private TextView firstDevice;
private TextView secondValue;
private TextView secondDevice;
private TextView secondValue2;
private ImageView firstImage, secondImage;
private View firstView, secondView;
private LinearLayout linear1, linear2;
jsonAsynctask jsonasynctask = new jsonAsynctask( this );
public SensorOversigtFragment() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate( R.layout.content_sensor_oversigt, container, false );
firstValue = (TextView) view.findViewById( R.id.firstValue );
firstDevice = (TextView) view.findViewById( R.id.firstDevice );
firstValue2 = (TextView) view.findViewById( R.id.firstValue2 );
secondDevice = (TextView) view.findViewById( R.id.secondDevice );
secondValue = (TextView) view.findViewById( R.id.secondValue );
secondValue2 = (TextView) view.findViewById( R.id.secondValue2 );
linear1 = (LinearLayout) view.findViewById( R.id.linear1 );
linear2 = (LinearLayout) view.findViewById( R.id.linear2 );
firstImage = (ImageView) view.findViewById( R.id.firstImage );
secondImage = (ImageView) view.findViewById( R.id.secondImage );
firstView = (View) view.findViewById( R.id.firstView );
secondView = (View) view.findViewById( R.id.secondView );
if (jsonasynctask.getStatus() == AsyncTask.Status.RUNNING) {
jsonasynctask.cancel( true );
} else if (jsonasynctask.getStatus() != AsyncTask.Status.RUNNING) {
jsonasynctask.execute();
}
return view;
}
@Override
public void onJobFinishListener(List<String> allId) {
//System.out.println( "LAST MODE: " + jsonasynctask.allMode.get( allId.size() - 1 ) );
for (int i = 0; i < allId.size(); i++) {
if (jsonasynctask.allDevice.get( i ).equals( "B42DB2" )) {
if (jsonasynctask.allMode.get( i ).equals( "0" )) {
linear1.setBackgroundColor( Color.parseColor( "#A9A9A9" ) );
firstDevice.setBackgroundColor( Color.parseColor( "#808080" ) );
firstDevice.setText( "STANDBY MODE" );
firstValue.setVisibility( View.GONE );
firstValue2.setVisibility( View.GONE );
firstImage.setColorFilter( Color.parseColor( "#A9A9A9" ) );
firstView.setBackgroundColor( Color.parseColor( "#A9A9A9" ) );
} else if (jsonasynctask.allMode.get( i ).equals( "1" )) {
linear1.setBackgroundColor( Color.parseColor( "#A0D468" ) );
firstValue.setBackgroundColor( Color.parseColor( "#8CC152" ) );
firstValue2.setBackgroundColor( Color.parseColor( "#8CC152" ) );
firstDevice.setBackgroundColor( Color.parseColor( "#8CC152" ) );
firstView.setBackgroundColor( Color.parseColor( "#A0D468" ) );
firstImage.setImageResource( R.drawable.lighticon );
firstValue.setText( jsonasynctask.allTemp.get( i ) + "°C" );
firstValue2.setText( jsonasynctask.allHum.get( i ) + "%" );
firstDevice.setText( jsonasynctask.allDevice.get( i ) );
firstValue.setVisibility( View.VISIBLE );
firstValue2.setVisibility( View.VISIBLE );
firstImage.setColorFilter( Color.parseColor( "#FFFFFF" ) );
} else if (jsonasynctask.allMode.get( i ).equals( "2" )) {
linear1.setBackgroundColor( Color.parseColor( "#FFCE54" ) );
firstValue.setBackgroundColor( Color.parseColor( "#F68B42" ) );
firstValue2.setBackgroundColor( Color.parseColor( "#F68B42" ) );
firstDevice.setBackgroundColor( Color.parseColor( "#F68B42" ) );
firstView.setBackgroundColor( Color.parseColor( "#FFCE54" ) );
firstImage.setImageResource( R.drawable.light_bulb_7_512 );
firstValue.setText( jsonasynctask.allLux.get( i ) );
firstValue2.setText( "Lux" );
firstDevice.setText( jsonasynctask.allDevice.get( i ) );
firstValue.setVisibility( View.VISIBLE );
firstValue2.setVisibility( View.VISIBLE );
firstImage.setColorFilter( Color.parseColor( "#FFFFFF" ) );
} else if (jsonasynctask.allMode.get( i ).equals( "3" )) {
linear1.setBackgroundColor( Color.parseColor( "#4FC1E9" ) );
firstValue.setBackgroundColor( Color.parseColor( "#3BAFDA" ) );
firstValue2.setBackgroundColor( Color.parseColor( "#3BAFDA" ) );
firstDevice.setBackgroundColor( Color.parseColor( "#3BAFDA" ) );
firstView.setBackgroundColor( Color.parseColor( "#4FC1E9" ) );
firstImage.setImageResource( R.drawable.ic_baseline_meeting_room_24px );
firstValue.setText( jsonasynctask.allDoor.get( i ) );
firstValue2.setText( "Door" );
firstDevice.setText( jsonasynctask.allDevice.get( i ) );
firstValue.setVisibility( View.VISIBLE );
firstValue2.setVisibility( View.VISIBLE );
firstImage.setColorFilter( Color.parseColor( "#FFFFFF" ) );
} else if (jsonasynctask.allMode.get( i ).equals( "4" )) {
linear1.setBackgroundColor( Color.parseColor( "#509CEC" ) );
firstValue.setBackgroundColor( Color.parseColor( "#4A89DC" ) );
firstValue2.setBackgroundColor( Color.parseColor( "#4A89DC" ) );
firstDevice.setBackgroundColor( Color.parseColor( "#4A89DC" ) );
firstView.setBackgroundColor( Color.parseColor( "#509CEC" ) );
firstImage.setImageResource( R.drawable.vibration );
firstValue.setText( jsonasynctask.allVib.get( i ) );
firstValue2.setText( "Vib" );
firstDevice.setText( jsonasynctask.allDevice.get( i ) );
firstValue.setVisibility( View.VISIBLE );
firstValue2.setVisibility( View.VISIBLE );
firstImage.setColorFilter( Color.parseColor( "#FFFFFF" ) );
} else if (jsonasynctask.allMode.get( i ).equals( "5" )) {
linear1.setBackgroundColor( Color.parseColor( "#EC87C0" ) );
firstValue.setBackgroundColor( Color.parseColor( "#D770AD" ) );
firstValue2.setBackgroundColor( Color.parseColor( "#D770AD" ) );
firstDevice.setBackgroundColor( Color.parseColor( "#D770AD" ) );
firstView.setBackgroundColor( Color.parseColor( "#EC87C0" ) );
firstImage.setImageResource( R.drawable.ic_magnet );
firstValue.setText( jsonasynctask.allMag.get( i ) );
firstValue2.setText( "Mag" );
firstDevice.setText( jsonasynctask.allDevice.get( i ) );
firstValue.setVisibility( View.VISIBLE );
firstValue2.setVisibility( View.VISIBLE );
firstImage.setColorFilter( Color.parseColor( "#FFFFFF" ) );
}
} else if (jsonasynctask.allDevice.get( i ).equals( "B42DC6" )) {
if (jsonasynctask.allMode.get( i ).equals( "0" )) {
linear2.setBackgroundColor( Color.parseColor( "#A9A9A9" ) );
secondDevice.setBackgroundColor( Color.parseColor( "#808080" ) );
secondDevice.setText( "STANDBY MODE" );
secondValue.setVisibility( View.GONE );
secondValue2.setVisibility( View.GONE );
secondImage.setColorFilter( Color.parseColor( "#A9A9A9" ) );
secondView.setBackgroundColor( Color.parseColor( "#A9A9A9" ) );
} else if (jsonasynctask.allMode.get( i ).equals( "1" )) {
linear2.setBackgroundColor( Color.parseColor( "#A0D468" ) );
secondValue.setBackgroundColor( Color.parseColor( "#8CC152" ) );
secondValue2.setBackgroundColor( Color.parseColor( "#8CC152" ) );
secondDevice.setBackgroundColor( Color.parseColor( "#8CC152" ) );
secondView.setBackgroundColor( Color.parseColor( "#A0D468" ) );
secondImage.setImageResource( R.drawable.lighticon );
secondValue.setText( jsonasynctask.allTemp.get( i ) + "°C" );
secondValue2.setText( jsonasynctask.allHum.get( i ) + "%" );
secondDevice.setText( jsonasynctask.allDevice.get( i ) );
secondValue.setVisibility( View.VISIBLE );
secondValue2.setVisibility( View.VISIBLE );
secondImage.setColorFilter( Color.parseColor( "#FFFFFF" ) );
} else if (jsonasynctask.allMode.get( i ).equals( "2" )) {
linear2.setBackgroundColor( Color.parseColor( "#FFCE54" ) );
secondValue.setBackgroundColor( Color.parseColor( "#F68B42" ) );
secondValue2.setBackgroundColor( Color.parseColor( "#F68B42" ) );
secondDevice.setBackgroundColor( Color.parseColor( "#F68B42" ) );
secondView.setBackgroundColor( Color.parseColor( "#FFCE54" ) );
secondImage.setImageResource( R.drawable.light_bulb_7_512 );
secondValue.setText( jsonasynctask.allLux.get( i ) );
secondValue2.setText( "Lux" );
secondDevice.setText( jsonasynctask.allDevice.get( i ) );
secondValue.setVisibility( View.VISIBLE );
secondValue2.setVisibility( View.VISIBLE );
secondImage.setColorFilter( Color.parseColor( "#FFFFFF" ) );
} else if (jsonasynctask.allMode.get( i ).equals( "3" )) {
linear2.setBackgroundColor( Color.parseColor( "#4FC1E9" ) );
secondValue.setBackgroundColor( Color.parseColor( "#3BAFDA" ) );
secondValue2.setBackgroundColor( Color.parseColor( "#3BAFDA" ) );
secondDevice.setBackgroundColor( Color.parseColor( "#3BAFDA" ) );
secondView.setBackgroundColor( Color.parseColor( "#4FC1E9" ) );
secondImage.setImageResource( R.drawable.ic_baseline_meeting_room_24px );
secondValue.setText( jsonasynctask.allDoor.get( i ) );
secondValue2.setText( "Door" );
secondDevice.setText( jsonasynctask.allDevice.get( i ) );
secondValue.setVisibility( View.VISIBLE );
secondValue2.setVisibility( View.VISIBLE );
secondImage.setColorFilter( Color.parseColor( "#FFFFFF" ) );
} else if (jsonasynctask.allMode.get( i ).equals( "4" )) {
linear2.setBackgroundColor( Color.parseColor( "#509CEC" ) );
secondValue.setBackgroundColor( Color.parseColor( "#4A89DC" ) );
secondValue2.setBackgroundColor( Color.parseColor( "#4A89DC" ) );
secondDevice.setBackgroundColor( Color.parseColor( "#4A89DC" ) );
secondView.setBackgroundColor( Color.parseColor( "#509CEC" ) );
secondImage.setImageResource( R.drawable.vibration );
secondValue.setText( jsonasynctask.allVib.get( i ) );
secondValue2.setText( "Vib" );
secondDevice.setText( jsonasynctask.allDevice.get( i ) );
secondValue.setVisibility( View.VISIBLE );
secondValue2.setVisibility( View.VISIBLE );
secondImage.setColorFilter( Color.parseColor( "#FFFFFF" ) );
} else if (jsonasynctask.allMode.get( i ).equals( "5" )) {
linear2.setBackgroundColor( Color.parseColor( "#EC87C0" ) );
secondValue.setBackgroundColor( Color.parseColor( "#D770AD" ) );
secondValue2.setBackgroundColor( Color.parseColor( "#D770AD" ) );
secondDevice.setBackgroundColor( Color.parseColor( "#D770AD" ) );
secondView.setBackgroundColor( Color.parseColor( "#EC87C0" ) );
secondImage.setImageResource( R.drawable.ic_magnet );
secondValue.setText( jsonasynctask.allMag.get( i ) );
secondValue2.setText( "Mag" );
secondDevice.setText( jsonasynctask.allDevice.get( i ) );
secondValue.setVisibility( View.VISIBLE );
secondValue2.setVisibility( View.VISIBLE );
secondImage.setColorFilter( Color.parseColor( "#FFFFFF" ) );
}
}
}
}
}
最佳答案
AsyncTask 崩溃可能是因为 onCreateView
在您的 fragment 实例上被多次调用,请尝试此操作以确保对于每个 execute() 调用您都有一个新实例
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate( R.layout.fragment_data_tabel, container, false );
sensor1 = (TextView) view.findViewById( R.id.sensorAlleBox );
new jsonAsynctask( this ).execute();
return view;
}
另一方面,如果您不喜欢一直创建新实例,请确保将调用包装在异步状态调用检查中,以确保您在运行时不会启动相同的异步:
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate( R.layout.fragment_data_tabel, container, false );
sensor1 = (TextView) view.findViewById( R.id.sensorAlleBox );
if(jsonasynctask.getState() != AsyncTask.Status.RUNNING){
jsonasynctask.execute();
}
return view;
}
最后,如果您在 AsyncTask 类中使用上下文,请确保使用 WeekReference 以确保您在 AsynTask 中没有持有强引用
关于android - 异步任务崩溃 ViewPager RecyclerView (Android),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52830684/
我目前面临将 ViewPager 放入另一个 ViewPager 中的问题,两者都可滑动。我成功创建了我的第一个 ViewPager,它包含三个页面,中间一个是第二个(内部)ViewPager,其中包
在我的主要 Activity 中,我有一个水平 viewpager。在 viewpager 的一个 fragment 中,我有另一个垂直 viewpager。两者都很好。但是对于水平 viewpage
我想创建一个 ViewPager(包含三个项目),其中每个 View 都是另一个 ViewPager(包含两个项目)。用户然后像这样滑动项目: ViewPager1[0] ViewPager2[0]
如何修复这个错误 setupWithViewPager(android.support.v4.view.ViewPager) in TabLayout cannot br applied to (an
我有一个包含 3 张图片的数组的 viewPage,我想在缩放其中一张时锁定 viewPager,因为当我在右侧滚动时,会出现下一张照片!这是我的代码 enter code here public
我是第一次实现 ViewPager,我遇到了一些问题,因为我收到以下错误: 06-20 10:40:51.366 11377-11377/com.example.ruelas.elite E/Andr
我真的是 android 的新手,如果对我的类(class)作业有任何帮助,我将不胜感激。 我需要做的: 1) 在一个 Activity 中有两个 ViewPagers(未嵌套) 2)两个ViewPa
我正在自定义我的 Android 应用程序以在四个方向上滑动,我正在使用 ViewPager 水平 和 VerticalViewPager 滑动垂直滑动(这就像对 DirectionalViewPag
我需要为平板电脑创建一个 ViewPager,在平板电脑的左侧会有导航按钮供用户选择。例如。 左侧导航将有 4 个图像按钮,每个项目将用户带到不同的教程。每个图像按钮都会加载一个 ViewPager。
我用过Vertical Viewpager在我的显示数据集合的项目中。在单个数据(项目)中,我有更多图像要显示。所以我尝试使用 viewpager。 但是当我水平滚动时,它会阻止垂直 Viewpage
我有一个父级 ViewPager,它的每个页面都包含一个子级 ViewPager。子 ViewPager 可能包含一个 ListView 或一个垂直的 ScrollView。我想将子级 ViewPag
我的任务是创建一个非常不正统的布局,只能通过另一个 viewpager 的第二个 Pane 内的 viewpager 来完成,幸运的是外部 viewpager 需要被锁定所以任务更现实一些,但是意外的
目标是根据屏幕方向(纵向或横向)以不同的布局在屏幕上显示两个 fragment ( fragment A、 fragment B)。 当设备处于纵向模式时,一次仅显示 Frag A 和 Frag B
我想禁用父 viewpager 中的子 viewpager 的滑动。 我目前使用这个自定义子 viewpager public class CustomViewPager extends ViewPa
我有两个 ViewPager - 一个在另一个下面。现在客户希望我们添加扩展底部 ViewPager(具有三个 ListView)以覆盖顶部 ViewPager 的可能性。当我将两个 ViewPage
我用谷歌搜索了这个问题很多天。找到一个解决方案,在Viewpager的开头和结尾添加一个空白View。当viewpager.getcurrentItem()==0时,则重新指向1。在我看来这种做法非常
我从适配器设置标题后,标题未出现在 PagerTabStrip 中 这是我的 Activity public class MainActivity extends AppCompatActivity
我有一个 ViewPager,其中包含多个 TextView,它们具有不同的字体大小。此外,我还获得了增加/减少字体大小的按钮,通过添加其默认大小加上一个名为 STEP 的值(该值通过 inc/dec
我有一个嵌套的 ViewPager,效果非常好。唯一的问题是,一旦子 ViewPager 位于最后一项并且我进一步滚动,父 ViewPager 就会滚动。我不想要这种行为。 我如何实现这一目标? 这是
我想显示一个带有滑动抽屉的 Viewpager。Viewpager 用于滚动图像,我想在该 viewpager 的顶部放置一个滑动抽屉(从顶部到按钮)。 我附上了我的示例代码。如果您对如何实现此屏幕有
我是一名优秀的程序员,十分优秀!