Home > Back-end >  Android studio
Android studio

Time:10-31

Android studio project running, click login will appear the following page, how to solve,

CodePudding user response:

refer to the original poster m0_46374690 response:
Android studio project running, click login will appear the following page, how to solve,

Problems occur in the following code, but I don't know where there is a problem,
Package com. Example. Myapplication. Activity; The import android. OS. Bundle; The import android. View. LayoutInflater; The import android. View. The view; The import android. View. ViewGroup; Window; import android. The view. The import android. Widget. ImageButton; The import android. Widget. LinearLayout; The import androidx. Appcompat. App. AppCompatActivity; The import androidx. Viewpager. Widget. PagerAdapter; The import androidx. Viewpager. Widget. The viewpager; The import com. Example. Myapplication. R; import java.util.ArrayList; import java.util.List; Public class dictActivity extends AppCompatActivity implements the View. An OnClickListener {private ViewPager mViewPager;//used for interface switching private PagerAdapter mPagerAdapter;//initialize the View adapter private List MViews=new ArrayList (a);//used to store Tab01-03//three tabs, each Tab includes a button private LinearLayout mTabshouye; Private LinearLayout mTabdingdan; Private LinearLayout mTabwode;//three buttons private ImageButton mshouyeImg; Private ImageButton mdingdanImg; Private ImageButton mwodeImg; @ Override protected void onCreate (Bundle savedInstanceState) {super. OnCreate (savedInstanceState); RequestWindowFeature (Window. FEATURE_NO_TITLE); The setContentView (R.l ayout. Activity_dict); InitView (); InitViewPage (); InitEvent (); } private void initEvent () {mTabshouye. SetOnClickListener (this); MTabdingdan. SetOnClickListener (this); MTabwode. SetOnClickListener (this); MViewPager. SetOnPageChangeListener (new ViewPager. OnPageChangeListener () {/* * * ViewPage slide around when the */@ Override public void onPageSelected (int arg0) {int currentItem=mViewPager. GetCurrentItem (); The switch (currentItem) {case 0: resetImg (); MshouyeImg. SetImageResource (R.d rawable. Tab_shouye); break; Case 1: resetImg (); MdingdanImg. SetImageResource (R.d rawable. Tab_dingdan); break; Case 2: resetImg (); MwodeImg. SetImageResource (R.d rawable. Tab_wode); break; Default: break; }} @ Override public void onPageScrolled (int arg0, float arg1, int arg2) {} @ Override public void onPageScrollStateChanged (int arg0) {}}); }/initialization Settings * * * */private void initView () {mViewPager=(ViewPager) the findViewById (R.i d.i d_viewpage);//initialize three LinearLayout mTabshouye=(LinearLayout) the findViewById (R.i d.i d_tab_shouye); MTabdingdan=(LinearLayout) the findViewById (R.i d.i d_tab_dingdan); MTabwode=(LinearLayout) the findViewById (R.i d.i d_tab_wode);//initialize the three buttons mshouyeImg=(ImageButton) the findViewById (R.i d.i d_tab_shouye_img); MdingdanImg=(ImageButton) the findViewById (R.i d.i d_tab_dingdan_img); MwodeImg=(ImageButton) the findViewById (R.i d.i d_tab_wode_img); }/initialization ViewPage * * * */private void initViewPage () {//initializes the four layout LayoutInflater mLayoutInflater=LayoutInflater. The from (this); The View tab01=mLayoutInflater. Inflate (R.l ayout. Tab01, null); The View tab02=mLayoutInflater. Inflate (R.l ayout. Tab02, null); The View tab03=mLayoutInflater. Inflate (R.l ayout. Tab03, null); MViews. Add (tab01); MViews. Add (tab02); MViews. Add (tab03);//adapter initialization and set mPagerAdapter=new PagerAdapter () {@ Override public void destroyItem (ViewGroup container, int the position, the Object Object) {container. RemoveView (mViews. Get (position)); } @ Override public Object instantiateItem (ViewGroup container, int position) {View View=mViews. Get (position); Container. AddView (view); Return the view; } @ Override public Boolean isViewFromObject (View arg0, Object arg1) {return arg0==arg1; } @ Override public int getCount () {return mViews. The size (); }}; MViewPager. SetAdapter (mPagerAdapter); {}} private void removeview (View View)/* * * judgment which to display, and the set up button picture */@ Override public void onClick (View arg0) {switch (arg0. GetId ()) {case R.i d.i d_tab_shouye_img: mViewPager. SetCurrentItem (0); ResetImg (); MshouyeImg. SetImageResource (R.d rawable. Tab_shouye); break; Case R.i d.i d_tab_dingdan_img: mViewPager setCurrentItem (1); ResetImg (); MdingdanImg. SetImageResource (R.d rawable. Tab_dingdan); break; Case R.i d.i d_tab_wode_img: mViewPager setCurrentItem (2); ResetImg (); MwodeImg. SetImageResource (R.d rawable. Tab_wode); break; nullnullnullnullnullnull