我的主要活动:
package pIEstudio.opinion;import androID.os.Bundle;import androID.support.design.Widget.floatingActionbutton;import androID.support.design.Widget.NavigationVIEw;import androID.support.design.Widget.Snackbar;import androID.support.v4.app.Fragment;import androID.support.v4.app.FragmentTransaction;import androID.support.v4.vIEw.G@R_404_6610@tyCompat;import androID.support.v4.Widget.DrawerLayout;import androID.support.v7.app.ActionbarDrawerToggle;import androID.support.v7.app.AppCompatActivity;import androID.support.v7.Widget.Toolbar;import androID.vIEw.Menu;import androID.vIEw.MenuItem;import androID.vIEw.VIEw;import com.Google.androID.gms.appindexing.AppIndex;import com.Google.androID.gms.common.API.Googleapiclient;public class MainActivity extends AppCompatActivity implements NavigationVIEw.OnNavigationItemSelectedListener { /** * ATTENTION: This was auto-generated to implement the App Indexing API. * See https://g.co/AppIndexing/AndroIDStudio for more information. */ private Googleapiclient clIEnt; @OverrIDe protected voID onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentVIEw(R.layout.activity_main); Toolbar toolbar = (Toolbar) findVIEwByID(R.ID.toolbar); setSupportActionbar(toolbar); floatingActionbutton fab = (floatingActionbutton) findVIEwByID(R.ID.fab); fab.setonClickListener(new VIEw.OnClickListener() { @OverrIDe public voID onClick(VIEw vIEw) { Snackbar.make(vIEw,"Replace with your own action",Snackbar.LENGTH_LONG) .setAction("Action",null).show(); } }); DrawerLayout drawer = (DrawerLayout) findVIEwByID(R.ID.drawer_layout); ActionbarDrawerToggle toggle = new ActionbarDrawerToggle( this,drawer,toolbar,R.string.navigation_drawer_open,R.string.navigation_drawer_close); drawer.setDrawerListener(toggle); toggle.syncState(); NavigationVIEw navigationVIEw = (NavigationVIEw) findVIEwByID(R.ID.nav_vIEw); navigationVIEw.setNavigationItemSelectedListener(this); // ATTENTION: This was auto-generated to implement the App Indexing API. // See https://g.co/AppIndexing/AndroIDStudio for more information. clIEnt = new Googleapiclient.Builder(this).addAPI(AppIndex.API).build(); } @OverrIDe public voID onBackpressed() { DrawerLayout drawer = (DrawerLayout) findVIEwByID(R.ID.drawer_layout); if (drawer.isDrawerOpen(G@R_404_6610@tyCompat.START)) { drawer.closeDrawer(G@R_404_6610@tyCompat.START); } else { super.onBackpressed(); } } @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(); //noinspection SimplifiableIfStatement if (ID == R.ID.action_settings) { return true; } return super.onoptionsItemSelected(item); } @SuppressWarnings("StatementWithEmptyBody") @OverrIDe public boolean onNavigationItemSelected(MenuItem item) { int ID = item.getItemID(); if (ID == R.ID.toi) { Fragment fragment = new Fragment(); FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); ft.replace(R.ID.content_frame,fragment); ft.commit(); return true; } else if (ID == R.ID.thehindu) { } else if (ID == R.ID.support) { } DrawerLayout drawer = (DrawerLayout) findVIEwByID(R.ID.drawer_layout); drawer.closeDrawer(G@R_404_6610@tyCompat.START); return true; } }
我创建了另一个片段名称FragmentOne
package pIEstudio.opinion;import androID.support.v4.app.FragmentActivity;import androID.vIEw.Menu;/** * Created by jene on 7/4/2016. */public class FragmentOne extends FragmentActivity { @OverrIDe public boolean onCreateOptionsMenu(Menu menu) { return super.onCreateOptionsMenu(menu); } }
因为我正在使用导航抽屉,所以这里是我的contentMain
<?xml version="1.0" enCoding="utf-8"?><relativeLayout xmlns:androID="http://schemas.androID.com/apk/res/androID" xmlns:app="http://schemas.androID.com/apk/res-auto" xmlns:tools="http://schemas.androID.com/tools" androID:layout_wIDth="match_parent" androID:layout_height="match_parent" androID:paddingBottom="@dimen/activity_vertical_margin" androID:paddingleft="@dimen/activity_horizontal_margin" androID:paddingRight="@dimen/activity_horizontal_margin" androID:paddingtop="@dimen/activity_vertical_margin" app:layout_behavior="@string/appbar_scrolling_vIEw_behavior" tools:context="pIEstudio.opinion.MainActivity" tools:showIn="@layout/app_bar_main"> <TextVIEw androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:text="Hello World!" /> <FrameLayout androID:layout_wIDth="match_parent" androID:layout_height="match_parent" androID:ID="@+ID/content_frame"/></relativeLayout>
fragment1(FragmentOne的xml文件)
<?xml version="1.0" enCoding="utf-8"?><linearLayout androID:layout_wIDth="match_parent" androID:layout_height="match_parent" androID:orIEntation="vertical" androID:ID="@+ID/fragment1" xmlns:androID="http://schemas.androID.com/apk/res/androID"> <TextVIEw androID:ID="@+ID/textVIEw1" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:layout_centerHorizontal="true" androID:layout_centerVertical="true" androID:text="one" /></linearLayout>解决方法 尝试关闭即时运行.
>打开“设置”或“首选项”对话框
>在windows或linux上,选择文件>主菜单中的设置.
>在Mac OSX上,选择AndroID Studio>主菜单中的首选项.
>导航到构建,执行,部署>即时运行
总结以上是内存溢出为你收集整理的android – 错误:computeFrames选项不支持JSR / RET全部内容,希望文章能够帮你解决android – 错误:computeFrames选项不支持JSR / RET所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)