我只想在我的Android应用中添加recyclerView。添加了recyclerView后,应用程序在启动画面后崩溃。
Splash.java
public class Splash extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
Intent loginintent = new Intent(Splash.this,Home.class);
Splash.this.startActivity(loginintent);
Splash.this.finish();
}
},3000);
}
}
Home.java
public class Home extends AppCompatActivity
implements NavigationView.OnNavigationItemSelectedListener {
private TabLayout tabLayout;
private ViewPager viewPager;
private int[] tabIcons = {
R.drawable.home,
R.drawable.faculty };
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
//private Toolbar toolbar;
viewPager = (ViewPager) findViewById(R.id.viewpager);
setupViewPager(viewPager);
tabLayout = (TabLayout) findViewById(R.id.tabs);
tabLayout.setupWithViewPager(viewPager);
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
.setAction("Action", null).show();
}
});
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.setDrawerListener(toggle);
toggle.syncState();
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);
setupTabIcons();
}
private void setupTabIcons() {
tabLayout.getTabAt(0).setIcon(tabIcons[0]);
tabLayout.getTabAt(1).setIcon(tabIcons[1]);
}
private void setupViewPager(ViewPager viewPager){
ViewPagerAdapter adapterCustom = new ViewPagerAdapter(getSupportFragmentManager());
adapterCustom.addFrag(new HomeTab(),"Home");
adapterCustom.addFrag(new NoticeTab(),"Notice");
viewPager.setAdapter(adapterCustom);
}
@Override
public void onBackPressed() {
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
if (drawer.isDrawerOpen(GravityCompat.START)) {
drawer.closeDrawer(GravityCompat.START);
} else {
super.onBackPressed();
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.home, 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) {
Intent information = new Intent(Home.this,Information.class);
startActivity(information);
return true;
}
return super.onOptionsItemSelected(item);
}
@SuppressWarnings("StatementWithEmptyBody")
@Override
public boolean onNavigationItemSelected(MenuItem item) {
// Handle navigation view item clicks here.
int id = item.getItemId();
if (id == R.id.home) {
// Handle the camera action
} else if (id == R.id.faculty) {
} else if (id == R.id.intdetail) {
Intent instDetail = new Intent(Home.this,About.class);
startActivity(instDetail);
} else if (id == R.id.nav_manage) {
} else if (id == R.id.nav_share) {
} else if (id == R.id.logout) {
SharedPreferences myPrefs = getSharedPreferences("Activity", MODE_PRIVATE);
SharedPreferences.Editor editor = myPrefs.edit();
editor.clear();
editor.commit();
AppState.getSingleInstance().setLoggingOut(true);
//Log.d(TAG, "Now log out and start the activity login");
Intent intent = new Intent(Home.this, Login.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
finish();
}
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
drawer.closeDrawer(GravityCompat.START);
return true;
}
} 这里我给的是这个应用程序的Logcat
E / lowmemorykiller:编写错误/ proc / 22911 / oom_score_adj; errno = 22 03-12 21:09:45.483 1501-1671 /?
E / InputDispatcher:channel' a154656 com.ajoy.gdp / com.ajoy.gdp.Home(server)' 〜频道不可挽回地被打破,将被处置! 03-12 21:09:45.483 1501-671 /?
E / InputDispatcher:channel' 26aeadf com.ajoy.gdp / com.ajoy.gdp.Splash(server)' 〜频道不可挽回地被打破,将被处置! 03-12 21:09:45.499 2637-2836 /? E / WtProcessController:错误pid或pid不存在
答案 0 :(得分:0)
试试这个
<?php
$sql = "SELECT * from students where id =".$id;
$result = $conn->query($sql);
$row = $result->fetch_assoc();
?>
<input type="text" name="firstName" id="firstName" value="<?php echo $row['first_name']; ?>">
<input type="text" name="lastName" id="lastName" value="<?php echo $row['last_name']; ?>">
<input type="text" name="age" id="age" value="<?php echo $row['age']; ?>">