小编the*_*st_的帖子

将例外作为包裹传递

我试图将异常传递给意图将相关信息转储到屏幕的活动.

目前我通过捆绑传递:

try {
    this.listPackageActivities();
} catch (Exception e) {
    Intent intent = new Intent().setClass(this, ExceptionActivity.class).putExtra("Exception", e);
    startActivity(intent);
}
Run Code Online (Sandbox Code Playgroud)

但当它到达那里时:

if (!(this.bundle.getParcelable("Exception") != null))
    throw new IndexOutOfBoundsException("Index \"Exception\" does not exist in  the parcel." + "/n"
    + "Keys: " + this.bundle.keySet().toString());
Run Code Online (Sandbox Code Playgroud)

抛出这个甜蜜的异常但是当我查看keySet和bundle的详细信息时,它告诉我有一个可以使用名为"Exception"的密钥的可分配对象.

我知道这与类型有关,但我不明白我做错了什么.我只想转储有关异常的信息,屏幕上的任何异常.有没有办法做到这一点,而不必每次都将所有信息压缩成一个字符串?

android

8
推荐指数
2
解决办法
4409
查看次数

TabControl.DrawItem不会在用户绘制的TabControl上触发

嘿,我一直在尝试绘制自己的TabControl以摆脱3D Shadow,但我没有取得多大成功.DrawItem事件此刻未触发.我必须亲自拍摄吗?我怎么做?

码:

namespace NCPad
{
    public partial class NCE_TabControl : TabControl
    {
        Rectangle TabBoundary;
        RectangleF TabTextBoundary;

        public NCE_TabControl()
        {
            InitializeComponent();
            this.SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.DoubleBuffer, true);
            this.DrawMode = TabDrawMode.OwnerDrawFixed;
            this.Paint += new PaintEventHandler(this.OnPaint);
            this.DrawItem += new DrawItemEventHandler(this.OnDrawItem);
        }

        protected void OnPaint(object sender, PaintEventArgs e)
        {
            Graphics g = e.Graphics;
            g.FillRectangle(new SolidBrush(Color.Red), e.ClipRectangle);
        }

        protected void OnDrawItem(object sender, DrawItemEventArgs e)
        {
            Graphics g = e.Graphics;
            g.FillRectangle(new SolidBrush(Color.Blue), this.TabBoundary);
            MessageBox.Show("hi");
        }

        protected override void OnLayout(LayoutEventArgs levent)
        {
            base.OnLayout(levent);

            this.TabBoundary = this.GetTabRect(0); …
Run Code Online (Sandbox Code Playgroud)

c# tabcontrol winforms

3
推荐指数
2
解决办法
7549
查看次数

列出包中的活动

我开始编写一个将成为参考实用程序的Android应用程序.

目前我正在将活动组织到包中,因此我想编写一个类,将列中包含的活动列入视图以建立层次结构.

我不知道如何向包裹索取该信息.

有关如何实现这一目标的任何想法?更好的应用程序设计技巧?

谢谢.

android packages list android-activity

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

标签 统计

android ×2

android-activity ×1

c# ×1

list ×1

packages ×1

tabcontrol ×1

winforms ×1