2013-03-26 22 views
0

В следующем коде, показанном ниже Я пытаюсь открыть новое действие (memo.class to view.class) при нажатии кнопки view.but, показывая ошибку «Исключенное действие исключение: неспособный найти явный класс активности ». что не так в моем коде ??? пожалуйста, помогите мнеНе удалось найти исключение: не удалось найти класс actitvity

мой код:

memo.xml

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="match_parent"> 

<TextView android:text="Titile" android:id="@+id/TextView01" android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView> 
<EditText android:id="@+id/question" android:layout_width="match_parent" android:layout_height="wrap_content" android:text=""></EditText> 
<TextView android:text="Text" android:id="@+id/TextView01" android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView> 
<EditText android:minLines="6" android:maxLines="10" android:id="@+id/answer" android:layout_width="match_parent" android:layout_height="wrap_content" android:text=""></EditText> 
<TableLayout android:layout_height="wrap_content" 
     android:layout_width="wrap_content" android:layout_gravity="center" 
     android:stretchColumns="*"> 
<TableRow> 
<Button android:id="@+id/add" android:layout_width="wrap_content" android:text="ADD" android:layout_height="wrap_content"></Button> 
<Button android:id="@+id/view" android:layout_width="wrap_content" android:text="VIEW" android:layout_height="wrap_content"></Button> 
</TableRow> 
</TableLayout> 
</LinearLayout> 

memo.java

package quesansw.the1; 

import android.app.Activity; 
import android.app.Dialog; 
import android.content.Intent; 
import android.os.Bundle; 
import android.view.View; 
import android.view.Window; 
import android.view.WindowManager; 
import android.widget.Button; 
import android.widget.EditText; 

public class Memo extends Activity{ 

    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 

     final Dialog d1 = new Dialog(this); 
     Window window = d1.getWindow(); 
     window.setFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND, 
       WindowManager.LayoutParams.FLAG_BLUR_BEHIND); 

     d1.setTitle("Register Questions"); 

     d1.setContentView(R.layout.memo); 
     d1.show(); 

     Button view1 = (Button) d1.findViewById(R.id.view); 
     Button add = (Button) d1.findViewById(R.id.add); 


     add.setOnClickListener(new View.OnClickListener() { 
      public void onClick(View v) 
      { 
       EditText add = (EditText) d1.findViewById(R.id.question); 
       EditText view = (EditText) d1.findViewById(R.id.answer); 
       System.out.println(add.getText()); 
       System.out.println(view.getText()); 


      } 
      }); 

     view1.setOnClickListener(new View.OnClickListener() { 
      public void onClick(View v) 
      { 
       Intent intent = new Intent(getBaseContext(), View.class); 
       startActivity(intent); 
      } 
    }); 
} 
} 

view.xml

<?xml version="1.0" encoding="utf-8"?> 

<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="match_parent"> 


<EditText android:id="@+id/question" android:layout_width="match_parent" android:layout_height="wrap_content" android:text=""></EditText> 
</LinearLayout> 

view.java

package quesansw.the1; 

import android.app.Activity; 
import android.app.Dialog; 
import android.os.Bundle; 
import android.view.Window; 
import android.view.WindowManager; 

public class View extends Activity { 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     final Dialog d1 = new Dialog(this); 
     Window window = d1.getWindow(); 
     window.setFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND, 
       WindowManager.LayoutParams.FLAG_BLUR_BEHIND); 

     d1.setTitle("Login"); 

     d1.setContentView(R.layout.view); 

     d1.show(); 
    } 

} 
+2

Вы можете подумать о присвоении названия вашему подклассу деятельности чем-то, кроме 'View' –

+0

@Kgrover Конечно, я ценю это. Я отвечу на ваш ответ. –

+0

@Tyler M.: Я хотел бы знать, почему вы не можете назвать класс «View» (я знаю, что View - это класс андроида и все). Но когда я искал его, я не смог найти правильный ответ. –

ответ

0

Вы, скорее всего, забыл включить его в Manifest.xml

+0

нет уже включено ... все еще получение ошибки – sid123

2

Вы должны объявить активность в манифесте:

<activity 
    android:name="com.yourpackagename.View"/> 

В принципе, ваш файл AndroidManifest.xml (найден в корневая папка пакета) действует как «настройки» или «главный контроллер» для всего вашего приложения, поэтому система должна знать каждую деятельность (по существу, страницу), которую вы будете переходить или использовать.

В файле манифеста есть другие вещи, которые могут быть в пределах Activity tag.

Боковое примечание: поскольку @Tyler M. говорит, вы должны использовать другое имя, чем «Вид» для своей деятельности.

+0

уже объявлено..после получения ошибки – sid123

+0

Попробуйте сделать, как @Tyler M. говорит и переименовывает деятельность. – Kgrover

+0

после изменения название его работы ..thanku – sid123

1

Переименуйте подкласс Activity на что-то, кроме View.

Как правило, плохая идея использовать имена существующих классов - это случайное бедствие, ожидающее своего появления.

Смежные вопросы