1
我無法弄清楚這一點。無論我點擊什麼,我的應用都會一直進入.Weather類。Android Studio總是打開相同的不正確頁面
package com.example.matmap;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.webkit.WebView;
import android.widget.LinearLayout;
import android.widget.Toast;
public class ResourcesPage extends Activity implements OnClickListener {
LinearLayout display;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_resources_page);
//display = (LinearLayout) findViewById(R.id.menuSweet);
LinearLayout locate = (LinearLayout) findViewById(R.id.locate);
LinearLayout ndsu = (LinearLayout) findViewById(R.id.ndsu);
LinearLayout weather = (LinearLayout) findViewById(R.id.weather);
LinearLayout contact = (LinearLayout) findViewById(R.id.contact);
locate.setOnClickListener(this);
ndsu.setOnClickListener(this);
weather.setOnClickListener(this);
contact.setOnClickListener(this);
}
@Override
public void onClick(View v) {
switch(v.getId()){
case R.id.locate:
Intent myIntent = new Intent(ResourcesPage.this, MapView.class);
startActivity(myIntent);
case R.id.ndsu:
Intent myIntent2 = new Intent(getApplicationContext(), TimesTable.class);
startActivity(myIntent2);
case R.id.weather:
Intent myIntent3 = new Intent(getApplicationContext(), Weather.class);
startActivity(myIntent3);
break; }
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.resources_page, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if(item.getItemId() == R.id.menuHome){
Intent i = new Intent(getApplicationContext(), ResourcesPage.class);
startActivity(i);
}
return true;
}
}
好一會MapView類
package com.example.matmap;
import android.app.Activity;
import android.os.Bundle;
public class MapView extends Activity{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_mapview);
}
}
我不知道是什麼問題,因爲我已經做過這些同樣的事情,它的工作完美...
哈哈謝謝!哎呀...猜我需要冷靜一點... x) – user2802752 2014-12-08 02:51:32
碰巧是我們最好的^^ – 2014-12-08 02:51:55