如何通过菜单转到另一个屏幕

时间:2015-04-30 04:19:22

标签: java android xml

我创建了一个菜单(Fack Call,Fake SMS,Statistic& About) 我希望这个文字带有一个图标 我试过了,但没办法 当我点击Fack Call,Fake SMS,Statistic text时,我也想转到另一个屏幕。

我该怎么做?

这是我的代码:

MainActivity.java

Password

FackCall.java

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // TODO Auto-generated method stub
        MenuInflater inflater = getMenuInflater();
        inflater.inflate(R.menu.main, menu);
        return true;
    }

    @SuppressWarnings("deprecation")
    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // TODO Auto-generated method stub
        switch (item.getItemId()) {
        case R.id.call:
            Toast.makeText(MainActivity.this, "call", Toast.LENGTH_SHORT)
                    .show();
            Intent intent = new Intent(this, FakeCall.class);
            startActivity(intent);
            return true;

        case R.id.sms:
            Toast.makeText(MainActivity.this, "sms", Toast.LENGTH_SHORT).show();
            return true;

        case R.id.statistic:
            Toast.makeText(MainActivity.this, "statistic", Toast.LENGTH_SHORT)
                    .show();
            return true;

        case R.id.about:

            Toast.makeText(MainActivity.this, "about", Toast.LENGTH_SHORT)
                    .show();
            return true;

        default:
            return super.onOptionsItemSelected(item);
        }
    }
}

main.xml中

public class FakeCall extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.fakecall);
    }

}

1 个答案:

答案 0 :(得分:0)

print [datetime.datetime(y,m,1) for y in range(2006,2010) for m in range(1,13)]