您将获得这些红色标记,因为这些类已在您先前的一个类中定义。Java不允许使用重复的名称。而且似乎您正在尝试为每个Actvitiy定义相同的类,这是多余的。
只需从SecondActivity
Java文件中完全删除这两个类,因为它们在上一个活动中已经定义。我建议您制作一个单独的程序包,在该程序包中定义Adapter和InfiniteGallery并保持重用。
public class SecondCity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Boolean customTitleSupported = requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); // Set the layout to use setContentView(R.layout.main); if (customTitleSupported) { getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE,R.layout.custom_title); TextView tv = (TextView) findViewById(R.id.tv); Typeface face=Typeface.createFromAsset(getAssets(),"BFantezy.ttf"); tv.setTypeface(face); tv.setText("MY PICTURES"); } InfiniteGallery galleryOne = (InfiniteGallery) findViewById(R.id.galleryOne); galleryOne.setAdapter(new InfiniteGalleryAdapter(this)); }}


