设置背景图片 - Android

时间:2013-10-02 10:06:51

标签: android xml

好的,所以我想在我的6个按钮,页眉和页脚后面设置一个背景图片,当别人点击它或类似的东西时,我不希望发生任何事情。 可以说背景png图像是“@ drawable / background”。

以下是屏幕显示内容的图片:http://i.stack.imgur.com/66MoI.png

这是我目前的相关代码:

dashboard_layout.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/home_root"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">

    <!-- Include Action Bar -->
    <include layout="@layout/actionbar_layout"/>

    <!--  Include Fragmented dashboard -->  
    <include layout="@layout/fragment_layout"/> 

    <!--  Include Footer -->
    <include layout="@layout/footer_layout"/>   

MenuActivity.java

public class MenuActivity extends Activity {

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.dashboard_layout);

    /**
     * Creating all buttons instances
     * */
    Button btn_chat = (Button) findViewById(R.id.btn_chat);

    Button btn_forums = (Button) findViewById(R.id.btn_forums);

    Button btn_donate = (Button) findViewById(R.id.btn_donate);

    Button btn_reports = (Button) findViewById(R.id.btn_reports);

    Button btn_commands = (Button) findViewById(R.id.btn_commands);

    Button btn_photos = (Button) findViewById(R.id.btn_photos);

    /**
     * Handling all button click events
     * */
    btn_chat.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            Intent i = new Intent(getApplicationContext(), ChatActivity.class);
            startActivity(i);
        }
    });

    btn_forums.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            Intent i = new Intent(getApplicationContext(), ForumsActivity.class);
            startActivity(i);
        }
    });

    btn_donate.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            Intent i = new Intent(getApplicationContext(), DonateActivity.class);
            startActivity(i);
        }
    });

    btn_reports.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            Intent i = new Intent(getApplicationContext(), ReportsActivity.class);
            startActivity(i);
        }
    });

    btn_commands.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            Intent i = new Intent(getApplicationContext(), CommandsActivity.class);
            startActivity(i);
        }
    });

    btn_photos.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            Intent i = new Intent(getApplicationContext(), PhotosActivity.class);
            startActivity(i);
        }
    });
}

}

先谢谢你们提前一英里:)

0 个答案:

没有答案