2012-07-27 3 views
0

내 환경 설정 화면에서 활동을 시작하려고하는데 도움이된다면 크게 도움이 될 것입니다. 여기에 내가 놀고있는 코드가있다.onPreferenceClick을 사용하여 활동 시작하기

Preference customerPref2 = (Preference) findPreference("community"); 
    customerPref2.setOnPreferenceClickListener(new OnPreferenceClickListener() { 

    public boolean onPreferenceClick(Preference preference) { 
       Toast.makeText(getBaseContext(), 
       "Launching Activity", 
       Toast.LENGTH_SHORT).show(); 
      Intent intent = new Intent();                 
      intent.setClassName("com.xxx.xxxx", "Community"); 
      intent.setClass(Prefs.this, Community.class); 
      startActivity(intent); 

내가 사용하는이 코드의 어떤 부분 몰라요, 그래서 내가 발견 한 무엇 setClassName 그냥 setClass

Preference.xml 또한

 <Preference 
      android:title="Checkout this Activity" 
      android:summary="Launch the Activity" 
      android:key="community"> 

    <intent android:action="android.intent.action.VIEW" 
     android:targetPackage="com.xxx.xxxx" 
     android:targetClass="com.xxx.xxxx.Community 

모두 포함 말하는 사람이다 당신의 매니페스트를 enusre하는 것이 옳다. 내가 활동을 시작하려 할 때 언젠가 그것을 찾을 수 없다고 말한다. 여기 내 매니페스트

<activity android:name=".Community" android:label="@string/gotodashboard"> 
     <intent-filter> 
      <action android:name="android.intent.category.VIEW" /> 
      <category android:name="android.intent.category.PREFERENCE" /> 
     </intent-filter> 
    </activity> 

어떤 도움이나 소스 코드 예제 날이 알아낼 도움이 될 것입니다. 고마워요.

답변

1

내 prefs java 파일의 코드를이 코드에 적용하여 질문을 해결했습니다.

public boolean onPreferenceClick(Preference preference) { 
    Intent myIntent = new Intent(Prefs.this, Community.class); 
    Prefs.this.startActivity(myIntent); 
    return true; 
    } 
관련 문제