Friday, 9 August 2013

Android Studio: Why my java code isn't recognized by layout?

Android Studio: Why my java code isn't recognized by layout?

I created new Java class Quiz that extends Activity and I created layout
for that new activity. When I click on a button that starts that new
activity, new layout for that new activity opens, but buttons and
everything else in that new activity doesn't response. It's like it
doesn't recognize the java code.
I know that the java code works because I used it in MainActivity and it
worked normally.
Does anyone know where could be a problem?
EDIT: I added codes.
Android Manifest:
<activity
android:name="com.domain.appname.Quiz"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.domain.appname.Quiz" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
layoutForActivity.xml
tools:context=".Quiz">
MainActivity
newButton= (Button)findViewById(R.id.button1);
newButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent openQuiz = new Intent("com.domain.appname.Quiz");
startActivity(openQuiz);
}
});
Quiz.java
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.layoutForActivity);
}

No comments:

Post a Comment