android this的用法~麻烦跟我解释一下这里面的几个this~/** Copyright (C) 2007 The Android Open Source Project** Licensed under the Apache License,Version 2.0 (the "License");* you may not use this file except in compliance with the Lice

来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/27 08:39:57
androidthis的用法~麻烦跟我解释一下这里面的几个this~/**Copyright(C)2007TheAndroidOpenSourceProject**LicensedundertheAp

android this的用法~麻烦跟我解释一下这里面的几个this~/** Copyright (C) 2007 The Android Open Source Project** Licensed under the Apache License,Version 2.0 (the "License");* you may not use this file except in compliance with the Lice
android this的用法~麻烦跟我解释一下这里面的几个this~
/*
* Copyright (C) 2007 The Android Open Source Project
*
* Licensed under the Apache License,Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* Unless required by applicable law or agreed to in writing,software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.example.android.apis.view;
import com.example.android.apis.R;
import android.app.Activity;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.Button;
import android.widget.TextSwitcher;
import android.widget.TextView;
import android.widget.ViewSwitcher;
/**
* Uses a TextSwitcher.
*/
public class TextSwitcher1 extends Activity implements ViewSwitcher.ViewFactory,
View.OnClickListener {
private TextSwitcher mSwitcher;
private int mCounter = 0;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.text_switcher_1);
mSwitcher = (TextSwitcher) findViewById(R.id.switcher);
mSwitcher.setFactory(this);
Animation in = AnimationUtils.loadAnimation(this,
android.R.anim.fade_in);
Animation out = AnimationUtils.loadAnimation(this,
android.R.anim.fade_out);
mSwitcher.setInAnimation(in);
mSwitcher.setOutAnimation(out);
Button nextButton = (Button) findViewById(R.id.next);
nextButton.setOnClickListener(this);
updateCounter();
}
public void onClick(View v) {
mCounter++;
updateCounter();
}
private void updateCounter() {
mSwitcher.setText(String.valueOf(mCounter));
}
public View makeView() {
TextView t = new TextView(this);
t.setGravity(Gravity.TOP | Gravity.CENTER_HORIZONTAL);
t.setTextSize(36);
return t;
}
}

android this的用法~麻烦跟我解释一下这里面的几个this~/** Copyright (C) 2007 The Android Open Source Project** Licensed under the Apache License,Version 2.0 (the "License");* you may not use this file except in compliance with the Lice
this 当前类(activity等)其指向是当前的.
比如程序中的nextButton.setOnClickListener(this);
这个this 就相当当前类的Context,即为,当期
如下,
nextButton.setOnClickListener(new OnClickListener() {
\x05\x05
\x05\x05@Override
\x05\x05public void onClick(View v) {
Toast.makeText(TextSwitcher1.this,"看这里",5000).show();
\x05\x05\x05}
在这个里面Toast(context,string,time),中,你直接写this 会出错的,因为你当前 的类是OnClickListener类.而不失我们的Activity 类,这样你写上去的会出现错误的!所以在内部类中你写this,指的是内部类,而不是外部的!this 就是当前,TextSwitcher1.this后面能调出TextSwitcher1的所有属性!
另外咱们在调用一些方法,传的Context 就是把当前类 传过去使用.
\x05\x05\x05
\x05\x05}
\x05};)

android this的用法~麻烦跟我解释一下这里面的几个this~/** Copyright (C) 2007 The Android Open Source Project** Licensed under the Apache License,Version 2.0 (the License);* you may not use this file except in compliance with the Lice android 中 new button(this) ,new button(getApplicationContext)的主要区别和用法 问下各位大虾android的MainActivity中setOnClickListener(this)中的this指代什么呀?还有就是为什么用this跟new OnClickListener(){}效果相同?我会加分的.this具体指代什么啊. Android开发中Intent的具体用法? Android中this.*与*.this还有*.class的区别是什么? 怎么新建一个ANDROID项目?new-other-android-android project但是弹出来的界面我要怎么继续? “button can not be resolved”这个错误是什么意思?这是我出现这个错误的部分代码:import android.view.View.OnClickListener;import android.app.Activity;import android.os.Bundle;import android.view.View;import android.widget.Butt 其中android:Theme android:Theme 是和@android:style/Theme 代表一个意思吗?我要想知道的是android:Theme 是和@android:style/Theme 是一个意思吗? 英语中的of有几种用法各位高手麻烦多举些of的用法跟例子 好心总有好报的 android开发中的几种上下文有什么区别,他们是否相同比如context Activity.this ,getApplicationContext 这几种上下文分别的用法.还有为什么在new ProgressDialog(Context context)的时候,传的上下文不能用getApplica 我的手机android系统重力感应器在那打开? this is my new watch.it was a present___my wife.中间填空填介词什么?顺便跟我说一下那些介词的用法 android:layout_margin=10dip; margin用法,他的意思是什么? dip是什么单位? Is this的用法 this指针的用法 this指针的用法 this的用法 this,that的用法