简体   繁体   English

Android Mainactivity不显示activity_main.xml

[英]Android Mainactivity doesn't show activity_main.xml

After I changed some of my app design at the activity_main.xml and launch the app the MainActivity class design doesn't change. activity_main.xml更改了部分应用程序设计并启动应用程序后, MainActivity类设计不会更改。 I tried to change the design after I changed the working space from tablet to android phone and the design doesn't fit on the phone the image views are too large and they fill all the phone screen any suggestions how to make it fit within the phone? 在我将工作空间从平板电脑更改为Android手机后,我尝试更改设计,并且设计不适合手机上的图像视图太大而且它们填满了所有手机屏幕的任何建议如何使其适合手机?

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bg_1"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.flagsgame.MainActivity" >

<LinearLayout
    android:id="@+id/linearLayout1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal" >

    <Button
        android:id="@+id/start_btn"
        android:layout_width="295dp"
        android:layout_height="wrap_content"
        android:text="@string/start_game" />
</LinearLayout>

<Button
    android:id="@+id/reguler"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/linearLayout1"
    android:layout_alignRight="@+id/linearLayout1"
    android:layout_below="@+id/linearLayout1"
    android:text="Classic Mode"
    android:visibility="invisible" />

<Button
    android:id="@+id/time"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/reguler"
    android:layout_alignRight="@+id/reguler"
    android:layout_below="@+id/reguler"
    android:text="Time Attack Maddness" 
    android:visibility="invisible"/>

public class MainActivity extends Activity implements OnClickListener {

private static final String TAG = "Flagss Game" ;//יצירת טאג למשחק לשימוש בםונקציות כמו exception

Button start;
Button time;
Button reguler;
DatabaseHandler db = new DatabaseHandler(this);

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    //List<Flagss> arrAdd= new ArrayList<Flagsss>();

    start = (Button)findViewById(R.id.start_btn);
    time = (Button)findViewById(R.id.time);
    reguler = (Button)findViewById(R.id.reguler);
    start.setOnClickListener(this);
    db = new DatabaseHandler(this);

    creat_rows();
}

/*
//קבלת התמונות
private void pic_view(String pic2) {

    // TODO Auto-generated method stub

    //Log.d("Result from pic function " , pic2);
    ImageView imageView = (ImageView)findViewById(R.id.imageView1);
    String uri ="@drawable/";
    uri += pic2;
    int imageResource = getResources().getIdentifier(uri, null, getPackageName());
    Drawable res= getResources().getDrawable(imageResource);
    imageView.setImageDrawable(res);

}*/

@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 void onClick(View v) {
    // TODO Auto-generated method stub
    start.setVisibility(start.INVISIBLE);
    time.setVisibility(time.VISIBLE);
    reguler.setVisibility(reguler.VISIBLE);

    //Intent s = new Intent(this,ClassicMode.class);
    //startActivity(s);

    reguler.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent cm = new Intent(MainActivity.this,ClassicMode.class);
            //Intent c = new Intent(MainActivity.class ,ClassicMode.class);
            startActivity(cm); 
        }
    });

    time.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            Intent tm = new Intent(MainActivity.this,TimeAttack.class);
            startActivity(tm);
            Log.d(TAG, "inside time");
        }
    });
}

Please ensure that you have kept activity_main.xml file in the correct layout directory. 请确保已将activity_main.xml文件保存在正确的布局目录中。 It is possible that you might have changed it for another kind of layout. 您可能已将其更改为另一种布局。 So verify all the activity_main.xml within your project. 因此,请验证项目中的所有activity_main.xml。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM