2015-01-30 10 views
0

목록의 버튼으로 ListActivity의 onListItemClick()에서 활동을 시작하지 못합니까?목록의 버튼을 사용하여 Listactivity의 onListItemClick에서 활동을 시작할 수 없습니까?

내가 버튼을 누르면 참조 된 활동에 참여할 수 없었습니다. 그것은 단지 클릭에도 해당 페이지에 남아 있습니다.

 public class Intro4 extends ListActivity{ 
String classes[] = {"Entertainment","TextPlay","Current-Affairs"}; 
public static int correct,wrong,marks; 
protected void onListItemClick(ListView l, View v, int position, long id) { 
    // TODO Auto-generated method stub 
    super.onListItemClick(l, v, position, id); 
     String cheese= classes[position]; 
     try { 
      Class ourClass = Class.forName("com.SVS."+cheese); 
      Intent ini= new Intent(Intro4.this,ourClass); 
      startActivity(ini); 
     } catch (ClassNotFoundException e) { 
      // TODO Auto-generated catch block 
      e.printStackTrace(); 
     } 
      } 
    @Override 
protected void onCreate(Bundle savedInstanceState) { 
    // TODO Auto-generated method stub 
    super.onCreate(savedInstanceState); 
    setListAdapter(new ArrayAdapter<String>(Intro4.this,android.R.layout.select_dialog_item,classes)); 
}} 

매니페스트는 : 여기

<uses-sdk 
    android:minSdkVersion="8" 
    android:targetSdkVersion="21" /> 

<application 
    android:allowBackup="true" 
    android:icon="@drawable/ic_launcher" 
    android:label="@string/app_name" 
    android:theme="@style/AppTheme" > 
    <activity 
     android:name=".Intro1" 
     android:label="@string/app_name" > 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 

      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter> 
    </activity> 
    <activity 
     android:name=".Intro2" 
     android:label="@string/app_name" > 
     <intent-filter> 
      <action android:name="com.SVS.INTRO2" /> 

      <category android:name="android.intent.category.DEFAULT" /> 
     </intent-filter> 
    </activity> 
    <activity 
     android:name=".Intro3" 
     android:label="@string/app_name" > 
     <intent-filter> 
      <action android:name="com.SVS.INTRO3" /> 

      <category android:name="android.intent.category.DEFAULT" /> 
     </intent-filter> 
    </activity> 
    <activity 
     android:name=".Intro4" 
     android:label="@string/app_name" > 
     <intent-filter> 
      <action android:name="com.SVS.INTRO4" /> 

      <category android:name="android.intent.category.DEFAULT" /> 
     </intent-filter> 
    </activity> 
    <activity 
     android:name=".Entertainment" 
     android:label="@string/app_name" > 
     <intent-filter> 
      <action android:name="com.SVS.ENTERTAINMENT" /> 

      <category android:name="android.intent.category.DEFAULT" /> 
     </intent-filter> 
    </activity> 
     <activity 
     android:name=".TextPlay" 
     android:label="@string/app_name" > 
      <intent-filter> 
      <action android:name="com.SVS.TEXTPLAY" /> 

      <category android:name="android.intent.category.DEFAULT" /> 
     </intent-filter> 
    </activity> 
    <activity 
     android:name=".MainActivity" 
     android:label="@string/app_name" > 
     <intent-filter> 
      <action android:name="com.SVS.MAINACTIVITY" /> 
      <category android:name="android.intent.category.DEFAULT" /> 
     </intent-filter> 
    </activity> 
</application> 

+0

logcat에서 무엇을 받았습니까? 예외 또는 어떤 오류? –

+0

시도 int ini = 새로운 의도 (intro4.this, ourClass.class); –

+0

확실한 클릭은 행 클릭에서 일어나는'onListItemClick'입니까? 로그 및 체크 메소드 사용 중 –

답변

0

:

문자열 클래스 [] = { "엔터테인먼트", "TextPlay", "전류 - 사무"};

Current-Affairs은 유효한 자바 식별자가 아닙니다. 자세한 내용은 Using Java Naming Conventions을 참조하십시오.

그리고 모든 활동 Entertainment,TextPlay,... 자바 제공자 라이선스 계약에 .. 내가 대답을 얻었다 AndroidManifest.xml

+0

"Current-Affairs"를 제거한 후에도 아무것도하지 않습니다. 그리고 AndroidManifest.xml에서 모든 행위를 확인했습니다 ... 문제가 해결되지 않았습니다 @ ρяσѕρєя K –

+0

@ KovuriVinay : use class ourClass = Class.forName ("com.SVS."+ 치즈); 인 텐트 ini = 새 인 텐트 (Intro4.this, ourClass); startActivity (ini);'try-catch'가없는 줄 ListView 행에서 어떤 일이 일어나는지 확인하십시오. 시도하지 않고 –

+0

을 클릭하십시오 .. 오류가 발생합니다. –

0

에 선언되어 있는지 확인하십시오 .. Class.forname("com.svs.blabla")
하지 ("com.SVS.blabla")

즉, 패키지 이름은 소문자에 있어야합니다.