0

I just started fiddling with android wear sdk . I created a list and found out that it normally renders with a top empty region.

enter image description here

I need that removed, but I couldn't find anything on it .

Muhammad Ahmed AbuTalib
  • 4,080
  • 4
  • 36
  • 59

1 Answers1

0

Go to your Adapter class and add a code as below:

private final Activity mContext;
private final Fragment[][] mFragment;

public MyGridViewPagerAdapter(Activity ctx, FragmentManager fm, Fragment[][] fragments)
{
  super(fm);
  mContext = ctx;
  this.mFragment = fragments;
}

then override the following methods:

@Override
public Fragment getFragment(int row, int col) 
{ 
  return mFragment[row][col]; 
}

@Override
public int getRowCount() 
{ 
  return mFragment.length; 
}

@Override
public int getColumnCount(int rowNum) 
{ 
  return mFragment[rowNum].length; 
}

then in your activity do as following:

@Override
protected void onCreate(Bundle savedInstanceState)
{
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_my);

  final GridViewPager pager = (GridViewPager) findViewById(R.id.pager);
  final Fragment[][] items = {
        {
                CusmtomFragment.newInstance("your","arguments"),
                CusmtomFragment.newInstance()
        },
        {
                OtherFragment.newInstance(),
                AnotherFragment.newInstance(1234)
        }
  };
  // ....
  pager.setAdapter(new MyGridViewPagerAdapter(this, getFragmentManager(), items));
}

Check also this issue: Is there any way to detect if the clock is round?

Hope it will help

Community
  • 1
  • 1
piotrek1543
  • 19,130
  • 7
  • 81
  • 94