標籤:
?
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????自動格式化代碼
註:如果快速鍵失效,請關閉搜狗IME的全域熱鍵。
????
?
由於很久沒有開啟過開發環境了:
居然不知多了一個fragment.xml的配置,調試的時候總是提示有問題:
在網上找到一個經驗:
?
- 將帶有fragment_***.xml的檔案刪除;
- 開啟對應的Activity,將ActionBarActivity替換為Activity;
- 去除PlaceholderFragment整個類
?
修改之前:
- publicclass TestActivity extendsActionBarActivity {
- ?
- [email protected]
- ???protectedvoid 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]
- ???publicboolean onCreateOptionsMenu(Menu menu) {
- ?
- ??????// Inflate the menu; this adds items to the action bar if it is present.
- ??????getMenuInflater().inflate(R.menu.test, menu);
- ??????returntrue;
- ???}
- ?
- [email protected]
- ???publicboolean 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) {
- ?????????returntrue;
- ??????}
- ??????returnsuper.onOptionsItemSelected(item);
- ???}
- ?
- ???/**
- ????* A placeholder fragment containing a simple view.
- ????*/
- ???publicstaticclassPlaceholderFragment 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;
- ??????}
- ???}
- }
修改之後:
- publicclass TestActivity extends Activity {
- ?
- [email protected]
- ???protectedvoid onCreate(Bundle savedInstanceState) {
- ??????super.onCreate(savedInstanceState);
- ??????setContentView(R.layout.activity_test);
- ???}
- ?
- [email protected]
- ???publicboolean onCreateOptionsMenu(Menu menu) {
- ?
- ??????// Inflate the menu; this adds items to the action bar if it is present.
- ??????getMenuInflater().inflate(R.menu.test, menu);
- ??????returntrue;
- ???}
- ?
- [email protected]
- ???publicboolean 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) {
- ?????????returntrue;
- ??????}
- ??????returnsuper.onOptionsItemSelected(item);
- ???}
- }
?
Android基礎環境搭建