IT科技资讯
联系方式
您现在的位置:主页 > IT科技资讯 > 内容

Android的学习3-初识Activity

发布时间:2019-01-26 编辑:918Õ

Activity---android的系统下存放控件的容器。通俗的讲相当于MFC中的CFrame。搭配完成android4.4.2开发环境后,发现比2.1的开发效率高很多。

android的2.1是依靠xml添加和表述控件,但4.4.2提供了可视化的编辑工具,加快了开发速度。

vcD4KPHA+MaGiyOe6zrvxyKG/2Lz+xNg/ztLDx7Lp1MRBY3Rpdml0ebXEsO/W+sAEvP63os/W09BmaW5kVmlld0J5SWS6r8r9oaPNqLn918rUtElEy/fS/b/YvP6hozwvcD4KPHA+MqGi0ae5/WphdmG1xMjLtrzWqrXAzO2800xpc3RlbmVyxNqyv8Dgo6zKtc/WYnV0dG9utcTE2rK/z+zTpjwvcD4KPHA+M6GiYnV0dG9uyejWw7zgzP2ho7nYwarE2rK/vODM/cDgoaM8L3A+CjxwPr7fzOW0+sLryOfPwjwvcD4KPHA+PC9wPgo8cHJlIGNsYXNzPQ=="brush:java;">package com.example.myactivity; import android.support.v7.app.ActionBarActivity; import android.support.v7.app.ActionBar; import android.support.v4.app.Fragment; import android.os.Bundle; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; import android.widget.Button; import android.os.Build; public class MainActivity extends ActionBarActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Button myButton = (Button)findViewById(R.id.button1); myButton.setOnClickListener(new myButtonListener()); if (savedInstanceState == null) { getSupportFragmentManager().beginTransaction() .add(R.id.container, new PlaceholderFragment()).commit(); } } class myButtonListener implements OnClickListener{ @Override public void onClick(View v) { // TODO Auto-generated method stub Button myButton = (Button)findViewById(R.id.button1); myButton.setText("HelloYyxhhx"); } } @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); } /** * A placeholder fragment containing a AAAAAA view. */ public AAAtic class PlaceholderFragment extends Fragment { public PlaceholderFragment() { } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main, container, false); return rootView; } } }程序初始界面如下

http://www.bkjia.com/Androidjc/764823.htmlwww.bkjia.comtruehttp://www.bkjia.com/Androidjc/764823.htmlTechArticleActivity---android的系统下存放控件的容器。通俗的讲相当于MFC中的CFrame。搭配完成android4.4.2开发环境后,发现比2.1的开发效率高很多。 andro...

本文源自: 揭秘环亚娱乐骗局

上一篇:AndroidAsyncHttp 临时修复 JsonHttpResponseHandler 避免死循环

下一篇:没有了

Copyright © 2005-2016 http://www.chickagoan.com 揭秘环亚娱乐骗局_揭秘环亚娱乐黑钱_环亚娱乐安全_网易新闻版权所有 揭秘环亚娱乐骗局_揭秘环亚娱乐黑钱_环亚娱乐安全_网易新闻