Thursday, February 27, 2014

Seek expert advice! ! Urgent


posts by small5e4444 on 2013-10-29 23:17:57 Edit
Intent problems


package = "com.example.viper"
android: versionCode = "1"
android: versionName = "1.0">
android: minSdkVersion = "8"
android: targetSdkVersion = "17" />


<-! Created in SDCard delete the file permissions on ->


android: allowBackup = "true"
android: icon = "@ drawable / ic_launcher">
android: name = "com.example.viper.MainActivity"
android: theme = "@ android: style / Theme.NoTitleBar.Fullscreen"
android: screenOrientation = "portrait"
>






android: name = "com.example.viper.ImagePagerActivity"
android: theme = "@ android: style / Theme.NoTitleBar.Fullscreen"
android: screenOrientation = "portrait"
>



Defines two Activity
When calling around for a little point, the structure would not be

public class MainActivity extends AbstructCommonActivity {

ListView viewBookList;

BookItemAdapter adapter;

LoadStateView loadStateView;

@ Override
protected void onCreate (Bundle savedInstanceState) {
super.onCreate (savedInstanceState);
setContentView (R.layout.main_1280);
viewBookList = (ListView) findViewById (R.id.viewBookList);

adapter = new BookItemAdapter (this, viewBookList);

loadStateView = (LoadStateView) findViewById (R.id.downloadStatusBox);

viewBookList.setAdapter (adapter);

reload ();

}
/ / Call another Activity
========================================public void changeActivity (int arg2) {
System.out.println ("arg2 ----:" + arg2);
Intent intent = new Intent (MainActivity.this, ImagePagerActivity.class);
System.out.println ("+ + + ok");
startActivity (intent);

}

}

Activity
------------------------ call / /public class ImagePagerActivity extends Activity {

ImageView iv;
@ Override
public void onCreate (Bundle savedInstanceState) {
super.onCreate (savedInstanceState);
setContentView (R.layout.picimage);

iv = (ImageView) findViewById (R.id.picOne);

}


}

The code, to achieve MainActivity call ImagePagerActivity, but will complain
at android.app.Activity.startActivityForResult (Activity.java: 3446)

I also tested the next, and if the above two classes also used in turn calls ImagePagerActivity call MainActivity no problem! ! !
seek expert guidance, I would like to MainActivity call ImagePagerActivity <-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
What prompted the error ah? AbstructCommonActivity What is this Activity? Its parent who is?
Reply:
AbstructCommonActivity I used to get phone resolution, the above procedure, and some code that I did not stick up on sticky Intent related
Reply:
Error is intent to null
java.lang.NullPointerException

Reply:
Add a landlord's intent in the startup activity in the new flag: Intent.FLAG_ACTIVITY_CLEAR_TOP try.
 intent.setFlags (Intent.FLAG_ACTIVITY_CLEAR_TOP); 

Reply:
The reply was deleted administrator at 2013-10-30 09:27:04

Reply:
Or not, ah, I was told to call this method in this general category changeActivity there a relationship?
Is not there have to be called Activity? !
Reply:
reference to the 6th floor small5e4444 reply:
or not, ah, I was told to call this method in the general category changeActivity there a relationship?
Is not there have to be called Activity? !

This is no ordinary class context? You want context passed in
 public void changeActivity (int arg2, Context context) {
System.out.println ("arg2 ----:" + arg2);
Intent intent = new Intent (context, ImagePagerActivity.class);
System.out.println ("+ + + ok");
context.startActivity (intent);
}

Reply:
. . . Will tantahe, context, how should I write
Reply:
public class BookItemAdapter extends BaseAdapter {

private LayoutInflater mInflater;
private Context mContext;
private Vector mModels = new Vector ();
private ListView mListView;
SyncImageLoader syncImageLoader;
MainActivity ma;

public BookItemAdapter (Context context, ListView listView) {
mInflater = LayoutInflater.from (context);
syncImageLoader = new SyncImageLoader ();
mContext = context;
mListView = listView;

ma = new MainActivity ();
mListView.setOnScrollListener (onScrollListener);
mListView.setOnItemClickListener (new OnItemClickListener () {/ / Click event
item
@ Override
public void onItemClick (AdapterView arg0, View arg1, int arg2,
long arg3) {
System.out.println ("position is:" + arg2);
/ / StartImagePagerActivity (arg2);
ma.changeActivity (arg2, mContext);
}

});
}

Forget sticky this code!

Or not ah, seeking guidance
Reply:
The latest error, but AndroidManifest which I define ImagePagerActivity! In the above post, write the wrong thing? !
android.content.ActivityNotFoundException: Unable to find explicit activity class {/ com.example.viper.ImagePagerActivity}; have you declared this activity in your AndroidManifest.xml?

No comments:

Post a Comment