my problem solved but another problem arises:
used:
// public constructor
public CannonView(Context context, AttributeSet attrs)
{
super(context, attrs); // call super's constructor
*activity = (Activity) context; *
.........
..........
SharedPreferences prefs = *activity.*getSharedPreferences("top5",
MODE_PRIVATE);
well if i have (same app) an activity and a Canvas like:
*public class CannonView extends SurfaceView *
* implements SurfaceHolder.Callback*
*{*
+
*public class CannonGame extends Activity*
*{*
And want record user name played what to do ... I use shared pref
in CannonView to record 5 top scores... when used get username dialog
success but in
public void onCreate(Bundle savedInstanceState) // Activity
{
super.onCreate(savedInstanceState); // call super's onCreate method
setContentView(R.layout.main); // inflate the layout
//userName = insertUser() ; /////////////////// line 104
// get the CannonView
cannonView = (CannonView) findViewById(R.id.cannonView);
//cannonView.asignVars(userName);//insertUser()
cannonView.userName=insertUser() ;
user is not recorded like non pass from Activity class (Main) to non
Activity class(canvas)... well is it because execution moved to canvas or
insertUser() may malfunction(thie latter not think so hence toast of user
name show works), well?
On Saturday, March 16, 2013 12:50:19 PM UTC+2, lselwd wrote:
>
>
> it seems i do not use context (in shared pref command)... i get it for an
> activity... i will retry...
>
> context is optional inside an activity, correct?
>
--
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
---
You received this message because you are subscribed to the Google Groups
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.