android arrayadapter 构造函数,无法解析构造函数ArrayAdapter

嗨大家我得到一个无法在我的OnCreateView方法中解析构造函数ArrayAdapter,我listAdapter试图在我的选项卡中列出文本数据,这是我的主要活动.任何帮助将不胜感激我仍然是一个noobie in Java.

public class MainActivity extends ActionBarActivity {

private Toolbar toolbar;

private ViewPager mPager;

private SlidingTabLayout mTabs;

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

toolbar = (Toolbar) findViewById(R.id.app_bar);

setSupportActionBar(toolbar);

mPager= (ViewPager) findViewById(R.id.viewPager);

mTabs=(SlidingTabLayout) findViewById(R.id.tabs);

mPager.setAdapter(new MyPagerAdapter(getSupportFragmentManager()));

mTabs.setDistributeEvenly(true);

mTabs.setBackgroundColor(getResources().getColor(R.color.colorPrimary));

mTabs.setSelectedIndicatorColors(getResources().getColor(R.color.colorAccent));

mTabs.setViewPager(mPager);

}

@Override

public boolean onCreateOptionsMenu(Menu menu) {

// Inflate the menu; this adds items to the action bar if it is present.

getMenuInflater().inflate(R.menu.menu_main, menu);

return true;

}

@Override

public boolean onOptionsItemSelected(MenuItem item) {

// Handle action bar item clicks here. The action bar will

// automatically handle clicks on the Home/Up button, so long

// as you specify a parent activity in AndroidManifest.xml.

int id = item.getItemId();

//noinspection SimplifiableIfStatement

if (id == R.id.action_settings) {

return true;

}

return super.onOptionsItemSelected(item);

}

class MyPagerAdapter extends FragmentPagerAdapter {

String[] tabs;

public MyPagerAdapter(FragmentManager fm) {

super(fm);

tabs=getResources().getStringArray(R.array.tabs);

}

@Override

public Fragment getItem(int position) {

MyFragment myFragment=MyFragment.getInstance(position);

return myFragment;

}

@Override

public CharSequence getPageTitle(int position) {

return tabs[position];

}

@Override

public int getCount() {

return 5;

}

}

public static class MyFragment extends Fragment {

private TextView textView;

private ListView mainListView;

private ArrayAdapter listAdapter ;

public static MyFragment getInstance(int position){

MyFragment myFragment=new MyFragment();

Bundle args=new Bundle();

args.putInt("position", position);

myFragment.setArguments(args);

return myFragment;

}

@Override

public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {

View layout=inflater.inflate(R.layout.fragment_my, container, false);

mainListView=(ListView) layout.findViewById(R.id.position);

String[] planets = new String[] { "Mercury", "Venus", "Earth", "Mars",

"Jupiter", "Saturn", "Uranus", "Neptune"};

ArrayList planetList = new ArrayList();

planetList.addAll( Arrays.asList(planets) );

listAdapter = new ArrayAdapter(this, R.layout.simplerow, planetList);

mainListView.setAdapter( listAdapter );

return layout;

}

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值