在PHP中get_called_class(),get_class($this)在实例中使用和之间的区别是什么?
例:
class A {
function dump() {
echo get_called_class();
echo get_class($this);
}
}
class B extends A {}
$A = new A();
$B = new B();
$A->dump(); // output is 'AA'
$B->dump(); // output is 'BB'
Run Code Online (Sandbox Code Playgroud)
这种情况有什么不同吗?
我什么时候应该使用其中一个get_called_class()或get_class($this)?
在我的xml布局中,我有一个自定义视图,我将在其中放置一些像:
<com.proj.layouts.components.ScrollLayout
android:id="@+id/slBody"
android:layout_width="700dp"
android:layout_height="400dp">
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="child1"/>
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="child2"/>
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="child3"/>
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="child4"/>
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="child5"/>
</com.proj.layouts.components.ScrollLayout>
Run Code Online (Sandbox Code Playgroud)
让我解释一下.我写了一个自定义ScrollView,我已经为孩子们定义了一个容器.所以我只想把它们放在那里.
public class ScrollLayout extends LinearLayout {
// View responsible for the scrolling
private FrameLayout svContainer;
// View holding all of the children
private LinearLayout llContainer;
public ScrollLayout(Context context) {
super(context);
init();
}
public ScrollLayout(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
private void init() {
super.removeAllViews(); // kill old containers
svContainer = …Run Code Online (Sandbox Code Playgroud) android android-custom-view android-layout android-xml android-resources
我正在尝试为php对象实现一些自动getter和setter.
我的目标是自动为每个属性的方法getProperty()和setProperty(value),这样,如果没有为脚本只是设置一个属性来实现或获得的价值的方法.
一个例子,让自己清楚:
class Foo {
public $Bar;
}
$A = new A();
$A->setBar("bar");
$A->getBar(); // -> output "bar"
Run Code Online (Sandbox Code Playgroud)
要么
class Foo {
public $Bar;
public function setBar($bar) { $Bar = $bar; }
public function getBar($bar) { return 'the value is: ' . $bar; }
}
$A = new A();
$A->setBar("bar");
$A->getBar(); // -> output "the value is: bar"
Run Code Online (Sandbox Code Playgroud)
关于如何实现这一点的任何想法/提示?
我正在尝试使用原生VideoView从服务器播放mp4视频流,遗憾的是我不断收到" 无法播放视频 "错误.
奇怪的是,同样的视频在Froyo上播放效果不错,但不会在HoneyComb上播放.我用MX Video Player(在HC上)尝试了相同的视频,它播放得很好.
另一个主要问题是我无法对视频进行重新编码,因此我必须按原样使用这些视频.
以下是logcat的详细信息:
E/MediaExtractor( 242): **********MediaExtractor::Create
D/DivXPlugin( 241): DivXPlugin::onInitialize : 75
D/DivXPlugin( 241): DivXPlugin::onSetOnInfoListener : 75
D/DivXPlugin( 241): DivXPlugin::onOpenDecryptSession: Enter : 75
E/DivXPlugin( 241): DivXPlugin::onOpenDecryptSession() Not a Divx File.
E/DrmManager(Native)( 241): DrmManager::openDecryptSession: no capable plug-in found
D/DivXPlugin( 241): DivXPlugin::onTerminate : 75
E/MediaExtractor( 242): ************Autodetected media content as 'video/mpeg4' with confidence 0.40
D/AwesomePlayer( 242): finishSetDataSource_l getDrmInfo
D/AwesomePlayer( 242): setDataSource_l
E/MPEG4Extractor( 242): ftyp chunk found
D/MPEG4Extractor( 242): kKeyAVCC found
E/MPEG4Extractor( …Run Code Online (Sandbox Code Playgroud) 我有一个AsyncTaskLoader长时间运行的任务,当加载器运行时,我的活动由于方向更改而被销毁,onLoadFinished不会调用回调.
我可以以某种方式'重新连接'加载器到我的新Activity /它的回调?
这是我的(简化)活动:
public class DashboardActivity extends BaseActivity {
StartupCallback startupCallback;
boolean loading = false;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.empty_viewpager);
startupCallback = new StartupCallback();
if (!loading){
getSupportLoaderManager().initLoader(GlobalApp.giveId(), null,
startupCallback);
loading = true;
}
}
private class StartupCallback implements
LoaderManager.LoaderCallbacks<Boolean> {
@Override
public void onLoadFinished(Loader<Boolean> loader, Boolean succ) {
Log.d("LOG", "onLoadFinished");
}
@Override
public Loader<Boolean> onCreateLoader(int id, Bundle args) {
return new StartupLoader(getApplicationContext());
}
@Override
public void onLoaderReset(Loader<Boolean> loader) {
} …Run Code Online (Sandbox Code Playgroud) 我在查找刚刚编辑的单元格的行和单元格索引时遇到问题DataGrid。我正在使用CellEditEnding事件来了解单元格何时被编辑。
到目前为止我已经成功地做了这样的事情。Col1包含属性DisplayIndex,即所选列的索引,但我无法以相同的方式找到。
private void DataGridData_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
{
DataGridColumn col1 = e.Column;
DataGridRow row1 = e.Row;
}
Run Code Online (Sandbox Code Playgroud) 虽然PHP中的类不需要明确扩展stdClass,但我想知道这样做是否存在某种最佳实践或好处.
stdClass在宣布上课时我应该延长吗?
有关参考,请参阅PHP中的什么是stdClass?和PHP:对象,转换为对象.
当我在之间切换时zoom to fill screen,stretch to fill screen我的应用程序将崩溃.顺便说一句,我注意到市场上很多应用程序都存在这个问题.有谁知道如何避免这个问题.
这是logcat:
E/AndroidRuntime(24475): FATAL EXCEPTION: main
E/AndroidRuntime(24475): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.macchetv.api/com.macchetv.activity.HomeActivity}: java.lang.ClassCastException: android.view.AbsSavedState$1 cannot be cast to android.widget.AbsListView$SavedState
E/AndroidRuntime(24475): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1818)
E/AndroidRuntime(24475): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1834)
E/AndroidRuntime(24475): at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3191)
E/AndroidRuntime(24475): at android.app.ActivityThread.access$600(ActivityThread.java:122)
E/AndroidRuntime(24475): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1031)
E/AndroidRuntime(24475): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(24475): at android.os.Looper.loop(Looper.java:132)
E/AndroidRuntime(24475): at android.app.ActivityThread.main(ActivityThread.java:4126)
E/AndroidRuntime(24475): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(24475): at java.lang.reflect.Method.invoke(Method.java:491)
E/AndroidRuntime(24475): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:844)
E/AndroidRuntime(24475): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
E/AndroidRuntime(24475): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime(24475): Caused by: java.lang.ClassCastException: android.view.AbsSavedState$1 cannot be cast to …Run Code Online (Sandbox Code Playgroud)