i have developed an app , which uses the settings using Preference Activity and Action Title Bar . When i press the three dots-> settings button , then it displays not responding , can u help .
매니페스트 파일의 코드는 메뉴 폴더에전화의 어떤 메뉴 버튼, 안드로이드 응용 프로그램의 설정 옵션을 사용할 수 없습니다
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="demoproject.swatygupta.com.demoproject_actionbar">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".Activity2_2PreferenceActivityScreen" />
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
XML 파일이
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:DemoProject_ActionBar="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context="demoproject.swatygupta.com.demoproject_actionbar.MainActivity">
<item
android:id="@+id/action_settings"
android:icon="@android:drawable/ic_menu_manage"
android:title="@string/action_settings"
DemoProject_ActionBar:showAsAction="never" />
이다 나는 응용 프로그램을 개발 이 대화 상자는 기본 설정 활동 및 작업 제목 표시 줄을 사용하여 설정을 사용합니다. 세 개의 점 -> 설정 버튼을 누르면 응답하지 않는 것으로 표시되어 도움이 될 수 있습니다.
주요 활동 클래스 메소드를 호출하는 동안 오류가있을 경우 찾아주십시오을 검색 할 수 있습니다 .-> public class MainActivity extends AppCompatActivity { @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(); } }); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { startActivity(new Intent(this, Activity2_2PreferenceActivityScreen.class)); return true; } return super.onOptionsItemSelected(item);} }
기본 설정 화면 활동 코드 ->
public final class Activity2_2PreferenceActivityScreen extends PreferenceActivity {
public Activity2_2PreferenceActivityScreen()
{
super();
} // constructor()
@Override
protected void onCreate(final Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preferences);
// Camera preference
final ListPreference PreferenceofCamera = (ListPreference) findPreference("camera");
setCameraPreferences(PreferenceofCamera);
PreferenceofCamera.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener(){
@Override
public boolean onPreferenceClick(Preference preference) {
setCameraPreferences(PreferenceofCamera);
return false;
}
});
// JPEG size preference
final ListPreference PreferenceofSize = (ListPreference) findPreference("size");
setSizePreferences(PreferenceofSize, PreferenceofCamera);
PreferenceofSize.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener(){
@Override
public boolean onPreferenceClick(Preference preference) {
setSizePreferences(PreferenceofSize, PreferenceofCamera);
return false;
}
});
} // onCreate(Bundle)
private void setCameraPreferences(final ListPreference cameraPreference)
{
final int numberOfCameras = Camera.getNumberOfCameras();
final CharSequence[] entries = new CharSequence[numberOfCameras];
final CharSequence[] entryValues = new CharSequence[numberOfCameras];
final Camera.CameraInfo Infoabtcamera = new Camera.CameraInfo();
for (int cameraIndex = 0; cameraIndex < numberOfCameras; cameraIndex++)
{
Camera.getCameraInfo(cameraIndex, Infoabtcamera);
String cameraFacing;
switch (Infoabtcamera.facing)
{
case Camera.CameraInfo.CAMERA_FACING_BACK:
cameraFacing = "Back";
break;
case Camera.CameraInfo.CAMERA_FACING_FRONT:
cameraFacing = "Front";
break;
default:
cameraFacing = "unknown";
} // switch
entries[cameraIndex] = "Camera " + cameraIndex + " " + cameraFacing;
entryValues[cameraIndex] = String.valueOf(cameraIndex);
} //for
cameraPreference.setEntries(entries);
cameraPreference.setEntryValues(entryValues);
} // setCameraPreferences(ListPreference)
private void setSizePreferences(final ListPreference sizePreference,
final ListPreference cameraPreference)
{
final String cameraPreferenceValue = cameraPreference.getValue();
final int cameraIndex;
if (cameraPreferenceValue != null)
{
cameraIndex = Integer.parseInt(cameraPreferenceValue);
} // if
else
{
cameraIndex = 0;
} // else
final Camera camera = Camera.open(cameraIndex);
final Camera.Parameters params = camera.getParameters();
camera.release();
final List<Camera.Size> supportedPreviewSizes = params.getSupportedPreviewSizes();
CharSequence[] entries = new CharSequence[supportedPreviewSizes.size()];
CharSequence[] entryValues = new CharSequence[supportedPreviewSizes.size()];
for (int previewSizeIndex = 0; previewSizeIndex < supportedPreviewSizes.size();
previewSizeIndex++)
{
Camera.Size supportedPreviewSize = supportedPreviewSizes.get(previewSizeIndex);
entries[previewSizeIndex] = supportedPreviewSize.width + "x"
+ supportedPreviewSize.height;
entryValues[previewSizeIndex] = String.valueOf(previewSizeIndex);
} // for
sizePreference.setEntries(entries);
sizePreference.setEntryValues(entryValues);
}/setSizePreferenceData(ListPreference)
}`
예, 툴바 (actionBar)를 추가하십시오! – lionscribe
@lionscribe how ?? 나를 도와 주실 수있으세요 ? 내 코드를 어디에서 변경해야합니까? 그러면 화면에 메뉴 유형 옵션이 생성됩니까? –
도 환경 설정/ –