小编use*_*343的帖子

为什么不允许继承成员?

我是C++的初学者,我正在做一个关于抽象类和继承的练习.

这是我的抽象类:

#ifndef   SHAPE_H 
#define  SHAPE_H
class Shape
{
    public:
        virtual void area();
        virtual void perimeter();
        virtual void volume();
};
#endif
Run Code Online (Sandbox Code Playgroud)

这是我实现抽象类的具体类:

#include <iostream>
#include <cmath>
#include "Shape.h"
using namespace std;

class Circle : public Shape
{
    public:
        Circle(int);
    private:
        int r;
};

Circle::Circle(int rad)
{
    r = rad;
}

void Circle::area()
{
    cout << "Area of this cirle = " << 3.14 * pow(r, 2) << endl;
}

void Circle::perimeter()
{
    cout << "Perimeter of this cirle = " …
Run Code Online (Sandbox Code Playgroud)

c++ inheritance

39
推荐指数
3
解决办法
4万
查看次数

我的片段无法转换为android.support.v4.app.Fragment

我创建了一个非常简单的片段来测试我的应用程序,我收到以下错误消息:

03-31 16:04:39.834: E/AndroidRuntime(7860): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.team3.domore/com.team3.domore.TabActivity}: java.lang.ClassCastException: com.team3.domore.SomeFrag cannot be cast to android.support.v4.app.Fragment
Run Code Online (Sandbox Code Playgroud)

我的片段很简单......

import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

public class SomeFrag extends Fragment {
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        return inflater.inflate(R.layout.alarm_frag, container, false);
    }

    @Override
    public void onStart() {
        super.onStart();
    }
}
Run Code Online (Sandbox Code Playgroud)

请帮忙......我已经挣扎了近两个小时..

编辑:我很确定我在哪里调用这个片段(扩展FragmentActivity的活动)正在工作......只是这个片段部分不起作用......

android fragment

23
推荐指数
2
解决办法
4万
查看次数

找不到绑定源

当我添加新选项卡然后将其删除时,我的应用程序将抛出此错误消息:

System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='System.Windows.Controls.TabControl', AncestorLevel='1''. BindingExpression:Path=TabStripPlacement; DataItem=null; target element is 'TabItem' (Name=''); target property is 'NoTarget' (type 'Object')
Run Code Online (Sandbox Code Playgroud)

如果我添加了一个新选项卡,切换到另一个选项卡,切换回来然后删除它,它没有抱怨.看起来像是在切换过程中"更新"的东西,但我无法弄清楚是什么以及如何解决它们.

这是我的xaml文件:

<Window x:Class="MyHomework__MVVM_.MyHomeworkView"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
       Title="My Homework" Height="450" Width="800" ResizeMode="CanMinimize">
    <Grid Margin="0,0,10,10">
        <TabControl HorizontalAlignment="Left" Height="330" VerticalAlignment="Top" Width="764" Margin="10,10,0,0" ItemsSource="{Binding AllTabs}" SelectedItem="{Binding SelectedTab}">
            <TabControl.ItemContainerStyle>
                <Style TargetType="TabItem">
                    <Setter Property="Header" Value="{Binding Header}"/>
                    <Setter Property="ContentTemplate">
                        <Setter.Value>
                            <DataTemplate>
                                <Grid>
                                    <TextBox Text="{Binding Text, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" FontSize="16" AcceptsReturn="True" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" TextChanged="OnTextChanged">
                                    </TextBox>
                                </Grid>
                            </DataTemplate>
                        </Setter.Value>
                    </Setter>
                    <Setter …
Run Code Online (Sandbox Code Playgroud)

c# wpf binding

22
推荐指数
2
解决办法
3976
查看次数

System.Collections.IDictionary不包含“设置”的定义?

 public partial class App : Application
    {
        private void OnExit(object sender, ExitEventArgs e)
        {
            Properties.Settings.Default.save();
        }
    }
Run Code Online (Sandbox Code Playgroud)

如何解决这个问题?我需要“注册”设置的任何地方吗?波浪线位于“设置”下方。

c# wpf

4
推荐指数
1
解决办法
1212
查看次数

Android生命周期:是否应该在启动时调用onResume()?

我正在尝试Android应用程序开发傻瓜的一个例子,这是一个简单的应用程序,切换手机的铃声模式.代码如下.

public class SilentModeToggleActivity extends Activity {

  private AudioManager mAudioManager;
  private boolean mPhoneIsSilent;

  @Override public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    mAudioManager = (AudioManager) getSystemService(AUDIO_SERVICE);
    checkIfPhoneIsSilent();
    setButtonClickListener();
  }

  @Override public void onResume() {
    super.onResume();
    checkIfPhoneIsSilent();
    toggleUi();
  }

  private void checkIfPhoneIsSilent() {
    int ringerMode = mAudioManager.getRingerMode();
    if (ringerMode == AudioManager.RINGER_MODE_SILENT) {
      mPhoneIsSilent = true;
    } else {
      mPhoneIsSilent = false;
    }
  }

  private void setButtonClickListener() {
    Button toggleButton = (Button) findViewById(R.id.toggleButton);
    toggleButton.setOnClickListener(new View.OnClickListener() {
      public void onClick(View v) { …
Run Code Online (Sandbox Code Playgroud)

android android-lifecycle

3
推荐指数
1
解决办法
4893
查看次数

标签 统计

android ×2

c# ×2

wpf ×2

android-lifecycle ×1

binding ×1

c++ ×1

fragment ×1

inheritance ×1