English 中文(简体)
甲状腺炎
原标题:android syntax problem with onActivtyresult

I am a beginner to android. I am trying to figure out the errors I am getting when using the following syntax:

 protected void onActivityResult(int requestCode, int resultCode, Intent data) {

The following are the errors: 1.void is an invalid type for the variable onActivityResult. 2.Syntax error on token "," ";" expected. 3. same as 2. 4.Syntax error on token "(" ";" expected. 5.Syntax error on token ")" ";" expected. Sorry if you find this question trivial.

最佳回答

您的班次<代码>活动。 我也认为你正在适当关闭这一方法:

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
    super.onActivityResult(requestCode, resultCode, intent);
    Log.d("TAG","requestCode = "+requestCode+" / resultCode = " +resultCode );
    // do other stuff
}
问题回答

<代码>oncreate(>外的书写。 这可能解决你的问题

public class User_info extends Activity {

Button b1;
EditText usernm , pwd ;
int request_code;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.user_info);
    request_code=1;
    b1=(Button)findViewById(R.id.submit);
    usernm=(EditText)findViewById(R.id.name);
    pwd=(EditText)findViewById(R.id.pwd);

    b1.setOnClickListener(new OnClickListener(){

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            Intent i=new Intent();
            startActivityForResult(i, request_code);

        }


    });


}

public void onActivityResult(int requestcode, int resultcode, Intent i )
{

}

}




相关问题
How to change out-of-focus text selection color in Xcode?

Okay, I ll bite. I ve got really pleasant code/window colors set up in Xcode. Ordinarily, my selection color is very visible. When I am doing a project search and iterating through the results, ...

pdo database abstraction

Can someone help me to see what is going wrong with this setup I build the @sql query in the function below like this. The extra quotes are setup in the conditions array. $sql .= " WHERE $...

I wish I could correlate an "inline view"

I have a Patient table: PatientId Admitted --------- --------------- 1 d/m/yy hh:mm:ss 2 d/m/yy hh:mm:ss 3 d/m/yy hh:mm:ss I have a PatientMeasurement table (0 to ...

Syntax help! Php and MYSQL

Original: $sql = "SELECT DATE(TimeAdded) AS Date, $column_name FROM Codes ORDER BY TimeAdded ASC"; Altered: $sql = "SELECT DATE("m", TimeAdded ) AS Date, ColumnName FROM TableName ORDER BY ...

Is this code Equivalent

I am not a fan of the following construction if (self = [super init]) { //do something with self assuming it has been created } Is the following equivalent? self = [super init]; if (self != ...

热门标签