1
我已經寫下了一段代碼,以引用名爲Forecast Fragment的類,並運行該應用程序。但第33行,我得到一個錯誤「無法解析符號‘機器人’」Android Studio,調用不同文件中的不同類
package com.example.sunshinepre_beta;
import android.os.Bundle;
import android.app.Activity;
import android.support.v7.app.ActionBarActivity;
import android.view.Menu;
import android.view.MenuItem;
public class MainActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
if (savedInstanceState == null) {
int commit = getSupportFragmentManager().beginTransaction()
.add(R.id.container, new com.example.android.sunshinepre_beta.app.ForecastFragment())
.commit();
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.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();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
當我嘗試這樣做時,自動完成會在整個返回之前帶回整個 – Kai 2014-11-02 02:16:33
不要使用自動完成:)然後將其鍵入。還要將ForecastFragment.java移動到MainActivity所在的同一文件夾中。 – 2014-11-02 02:20:27