Note that there are some explanatory texts on larger screens.

plurals
  1. POError R.id && Theme.AppCompat.Light when i make Action
    primarykey
    data
    text
    <p>When i Edited it's still error when i edit finish .this is my code MainActivity</p> <pre><code>package com.example.actionbar; import android.os.Bundle; import android.app.Activity; import android.view.Menu; import android.view.MenuItem; import android.widget.Toast; public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); getActionBar().setDisplayHomeAsUpEnabled(true); } @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; } //ถ้ามีการเลือก actionเกิดขึ้น object ที่นำมาใช้จะเรียกชื่อobject นี้ว่า onOptionItemSelected() public boolean onOptionItemSelect(MenuItem item){ //ใช้switch case ในการกำหนดว่าเมือ เลือก action นี้เเล้วทำอะไร switch (item.getItemId()){ case R.id.action_search: Toast.makeText(this,"Menu search is selected", Toast.LENGTH_SHORT).show(); break; case R.id.action_settings: Toast.makeText(this,"Menu setting is selected", Toast.LENGTH_SHORT).show(); break; default: break; } return true; } } </code></pre> <p>Now i add string to string.xml </p> <pre><code>&lt;string name="action_search"&gt;Search&lt;/string&gt; </code></pre> <p>This is my code in res/menu/main</p> <pre><code>&lt;item android:id="@+id/action_search" android:icon="@drawable/ic_action_search" android:name="@string/action_search" android:showAsAction="ifRoom"/&gt; </code></pre> <p>This is my code at manifest error at (android:label="@string/Theme.AppCompat.Light") .</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.actionbar" android:versionCode="1" android:versionName="1.0" &gt; &lt;uses-sdk android:minSdkVersion="11" android:targetSdkVersion="18" /&gt; &lt;application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" &gt; &lt;activity android:name="com.example.actionbar.MainActivity" android:label="@string/Theme.AppCompat.Light" &gt; &lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;error &lt;intent-filter&gt; &lt;action android:name="android.intent.action.MAIN" /&gt; &lt;category android:name="android.intent.category.LAUNCHER" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; &lt;/application&gt; &lt;/manifest&gt; </code></pre> <p>this my error in R &amp; Theme.AppCompat.Light. </p> <pre><code> R cannot be resolved to a variable No resource found that matches the given name (at 'label' with value '@string/Theme.AppCompat.Light') </code></pre> <p>How can i do ?? thank you</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload