2012-06-15 2 views
0

Добрый день, я пытаюсь начать новую деятельность с другой. Но он всегда разбивался. Здесь мой код. Это событие в ListView.Не можете начать новую активность

list.setOnItemClickListener(new OnItemClickListener(){ 
      public void onItemClick(AdapterView<?> parent, View view, int position, long id){ 
       Student selected = (Student)list.getItemAtPosition(position); 
       String selectedTitle = selected.FirstName; //ideally this would probably be done with accessors 
       int selectedId = selected.studentId; 
       String selectedDescription = selected.LastName; 

       Intent i = new Intent(view.getContext(), StudentInfoActivity.class); 
       i.putExtra("studentId", selectedId); 
       try{ 
        startActivity(i); 
       }catch (Exception e) { 
        // TODO Auto-generated catch block 
        e.printStackTrace(); 
       } 

      } 
     }); 

на добавленную активность в манифеста

<activity 
      android:name=".StudentInfoActivity" 
      android:label="@string/app_name" > 
     </activity> 

Сообщение об ошибке

06-15 17:17:00.471: E/AndroidRuntime(602): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.marat.mutw/com.marat.mutw.StudentInfoActivity}: java.lang.NullPointerException: uriString 

Все мероприятия previus, те, которые я добавил прекрасно работает ...

StudentInfoActivity

public class StudentInfoActivity extends Activity { 

    ImageView image; 
    TextView firstLastName; 
    TextView studentInfo; 
    TextView addInfo; 
    Student std; 

    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.sudentinfolayout); 

     image = (ImageView)findViewById(R.id.avatar); 
     firstLastName = (TextView)findViewById(R.id.firstNameLastName); 
     studentInfo = (TextView)findViewById(R.id.studentinfo); 
     addInfo = (TextView)findViewById(R.id.description); 

     int studentId = getIntent().getExtras().getInt("studentId"); 
     JSONHandler handler = new JSONHandler(this.getApplicationContext()); 
     std = new Student(); 
     std = handler.GetStudentInfo(studentId); 
     image.setImageURI(Uri.parse(std.imagePath)); 
     firstLastName.setText(std.FirstName+ " "+std.LastName); 




    } 
    public void onClickApply(View view){ 

    } 

} 
+0

Можете ли вы разместить свою сборку для StudentInfoActivity? – jsb

+0

проблема в StudentInfoActivity.java, пожалуйста, укажите, что –

+0

Что такое 'uriSting' здесь? И разместите свой 'StudentInfoActivity.java' – Praveenkumar

ответ

1

вместо

Intent i = new Intent(view.getContext(), StudentInfoActivity.class); 

изменение

Create static object of that activity 

активность например ацетон = NULL;

public static actOne a ; 
a = this; 

Intent i = new Intent(a, StudentInfoActivity.class); 
+0

Спасибо, это помогает =) – nabiullinas

0

попробуйте этот.

Intent i = new Intent(getApplicationContext(), StudentInfoActivity.class); 
i.putExtra("studentId", selectedId); 
startActivity(i); 
Смежные вопросы