The first solution

New version installation SDK The file starts with two XML file ,activity_main.xml and fragment_main.xml,
Those who are not used to it can be dealt with in this way :
1. Delete fragment_main.xml The whole document
2. Yes activity_main.xml, Delete the contents . And then switch to Graphy Layout, Put one in LinearLayout Can
3. Yes, You can delete part of the content , And then MainActivity extends ActionBarActivity Change it to MainActivity extends Activity :
It's changed to read as follows :
package com.zmcorp.weightcalculator;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.os.Build;

MainActivity extends Activity {

protected void onCreate(Bundle savedInstanceState) {


public boolean onCreateOptionsMenu(Menu menu) {

// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(, menu);
return true;

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 == {
return true;
return super.onOptionsItemSelected(item);



The second method ::

myTextview,myButton Is in fragment_main.xml Medium , In the absence of introduction fragment_main.xml Before , You are through findViewById I can't find ..

public static class PlaceholderFragment extends Fragment {

public PlaceholderFragment() {

public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_main, container,
TextView textview = (TextView)rootView.findViewById(;
testview.setText("Hello Android!");

return rootView;

About activity_main.xml And fragment_main.xml More articles about

  1. layout In the folder activity_main.xml And fragment_main.xml Records of document processing

    androidSDK Update to 22.6 When you build a new project after layout There's... Under the folder activity_main.xml And fragment_main.xml, This is to use fragmentation in tablet development , But let people who don't need debris ...

  2. activity_main.xml And fragment_main.xml

    see : ...

  3. Andriod ADT v22.6.2 Version in Use in fragment_main.xml in TextView Control object

    as everyone knows , We can be in  activity_main.xml File control activity Medium view, You can also use java Code set..() How to control it . In the learning process , Found in ADT In the new version , It's different from the previous version ...

  4. Android in fragment_main.xml The problem of getting components in the file

    package com.dhy.phonedial; import; import; import android. ...

  5. Android On fragment_main.xml File problem component acquisition

    package com.dhy.phonedial; import; import; import android. ...

  6. Android Remove the new Android fragment_main.xml

    In the new edition of ADT in , establish androidproject By default, two xml file --fragment_main and activity_main. I suggest that fragment_main Delete this file 1) take ...

  7. Maven actual combat :pom.xml And settings.xml

    pom.xml And settings.xml pom.xml And setting.xml, Can be said to be Maven The two most important configuration files in , To determine the Maven Core functions , Although the previous articles mentioned it piecemeal pom.xml and s ...

  8. according to xml File name get xml Data and transform it into entities .

    1. Define a xml file . <?xml version="1.0" encoding="utf-8" ?> <UserManager xmlns ...

  9. Why? applicationContext.xml and spring-servlet.xml There's annotation filtering in all of them &lt;context:component-scan base-package=&quot;myproject&quot;&gt; and &lt;context:component-scan base-package=&quot;myproject.controller&quot; /&gt;

    In the study SpringMVC When the framework is integrated , You may wonder why Spring.xml and SpringMVC.xml There's annotation filtering in all of them . <context:component-scan base-packa ...

Random recommendation

  1. [ACM_ Dynamic programming ] Nested rectangles

    Problem description : Yes n Matrix , Each matrix can use two integers a,b To express , It means his length and width , matrix X (a,b) Sure nesting To Y (c,d) Inside if and only if a < c &&  b < d  ...

  2. wangEditor—— Lightweight web Rich text box

    wangEditor—— Lightweight web Rich text editor See  perhaps hand over ...

  3. MyEclipse in SVN How to use

    Reprinted from   ----- Sina blog MyEclipse Medium SVN Operation manual 1. Import the project Click on the toolbar [File-Import], Enter the figure below

  4. JvisualVM、JMC Monitoring remote servers

    Modify the server jmxremote.access And jmxremote.password, Enter the command : find -name jmxremote.access Access to the jmxremote.access File directory ...

  5. Mainstream page editors :TinyMCE VS FCKeditor

    First used in development is FCKeditor Editor , I feel that the things displayed on the page are too cumbersome , So I changed it TinyMCE Editor . For ease of understanding , This paper does not use interspersed comparison First look at  FCKeditor : 1.jsp : The end tag cannot be attached ...

  6. Starting from scratch, wechat small program development

    Preface : ha-ha , I found that all my essays were project driven . Of course , This is also project driven , Some time ago, when playing wechat, leaders found the benefits of wechat app , technological process , Fast switching speed, etc , Then let me study the implementation of small programs . Under the supplement , Blogs mostly deal with ...

  7. OminiMarkupPreview Shortcut key

    The default key bindings: Windows, Linux: Ctrl+Alt+O: Preview Markup in Browser. Ctrl+Alt+X: Export ...

  8. BZOJ 1041: [HAOI2008] The whole point on the circle 【 number theory , solve equations 】

    1041: [HAOI2008] The whole point on the circle Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 4210  Solved: 1908[Submit][Sta ...

  9. vue-- Animation shrinks

    First install vuex establish store Folder stay store The folders are created separately state.js // State management // Definition state Raw data const state = { fullScre ...

  10. HDU4278

    Faulty Odometer Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)T ...