I kind of asked this project before, but I have come across new problems and new ideas I want to share.
I am trying to draw a multitude of the same graphic randomly spaced.
Here is the first activity code that transitions to the second activity code:
package com.category.tap;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.ImageButton;
public class TitleActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_title);
ImageButton switchButton = (ImageButton) findViewById(R.id.play);
switchButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(TitleActivity.this, GameActivity.class);
startActivity(intent);
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.title, menu);
return true;
}
}
The second activity code is:
package com.category.tap;
import android.app.Activity;a
import android.os.Bundle;
import android.view.Menu;
public class GameActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_game);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.game, menu);
return true;
}
}
The overwritten onDraw:
package com.category.tap;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.view.View;
public class DrawV extends View {
public DrawV(Context context){
super(context);
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
Bitmap bit_dot = BitmapFactory.decodeResource(getResources(), R.drawable.dot_catch);
canvas.drawBitmap(bit_dot, 100, 100, null);
canvas.drawBitmap(bit_dot, -30, -30, null);
}
}
Lastly, the layout for the game activity:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".GameActivity"
android:text="@string/ShowText" >
<View
class="com.category.tap.DrawV"
android:layout_width="100dp"
android:layout_height="100dp" />
</RelativeLayout>
The problem: After clicking on the button from the first activity's layout, the transitioned to second screen is a white screen. Also, at the bottom of the logcat screen, the bottom M's fluctuate from 80M of 300M to 110 of 300M. Also, what in the listed game layout should be drafted for What folder names or terms between periods do I use for this value? The 100, 100 and -30, -30 graphic values are just testing boundaries (-). Also, android:text="@string/ShowText" in the Game Layout does not display either.
The only red logcat entries are intermittent
03-05 13:27:52.020: E/KINETO(243): KLOG082- 01 00 09 02 00 00 00 00
03-05 13:27:55.020: E/KINETO(243): KLOG082- 01 00 09 02 00 00 00 00
etc.
Thanks for any help. I am really stuck.
See Question&Answers more detail:
os