?
1.安装JDK
从官网下载JDK安装,
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
我选择的如上图红色,为jdk1.8.0_45。
?
安装好JDK之后,会提示安装JRE,请保持安装在同一目录:如均在"Java"目录下
?
2.配置环境变量
- 新建JAVA_HOME:选择jdk的安装路径,如K:\Java\jdk1.8.0_45
- Path中增加:%JAVA_HOME%\bin;%JAVA_HOME%\jre\bin;
- 新建CLASSPATH:.;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar;
- 验证
?
?
java和javac命令都通过,则说明配置好了!
?
3.下载ADT
由于不知怎么找到,从百度云盘搜索了一个。
?
4.实用工具
Ctr +shift+O 自动添加包
Ctr+/????????注释代码
Ctr+Shit+F????自动格式化代码
注:如果快捷键失效,请关闭搜狗输入法的全局热键。
????
?
由于很久没有打开过开发环境了:
居然不知多了一个fragment.xml的配置,调试的时候总是提示有问题:
在网上找到一个经验:
?
- 将带有fragment_***.xml的文件删除;
- 打开对应的Activity,将ActionBarActivity替换为Activity;
- 去除PlaceholderFragment整个类
?
修改之前:
- public
class TestActivity extends
ActionBarActivity { - ?
- [email protected]
- ???protected
void onCreate(Bundle savedInstanceState) { - ??????super.onCreate(savedInstanceState);
- ??????setContentView(R.layout.activity_test);
- ?
- ??????if (savedInstanceState == null) {
- ?????????getSupportFragmentManager().beginTransaction()
- ???????????????.add(R.id.container, new PlaceholderFragment()).commit();
- ??????}
- ???}
- ?
- [email protected]
- ???public
boolean onCreateOptionsMenu(Menu menu) { - ?
- ??????// Inflate the menu; this adds items to the action bar if it is present.
- ??????getMenuInflater().inflate(R.menu.test, menu);
- ??????return
true; - ???}
- ?
- [email protected]
- ???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 simple view.
- ????*/
- ???public
static
class
PlaceholderFragment extends Fragment { - ?
- ??????public PlaceholderFragment() {
- ??????}
- ?
- [email protected]
- ??????public View onCreateView(LayoutInflater inflater, ViewGroup container,
- ????????????Bundle savedInstanceState) {
- ?????????View rootView = inflater.inflate(R.layout.fragment_test, container,
- ???????????????false);
- ?????????return rootView;
- ??????}
- ???}
- }
修改之后:
- public
class TestActivity extends Activity { - ?
- [email protected]
- ???protected
void onCreate(Bundle savedInstanceState) { - ??????super.onCreate(savedInstanceState);
- ??????setContentView(R.layout.activity_test);
- ???}
- ?
- [email protected]
- ???public
boolean onCreateOptionsMenu(Menu menu) { - ?
- ??????// Inflate the menu; this adds items to the action bar if it is present.
- ??????getMenuInflater().inflate(R.menu.test, menu);
- ??????return
true; - ???}
- ?
- [email protected]
- ???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); - ???}
- }
?
时间: 2024-10-13 11:22:42