当前位置: 首页>>代码示例>>Java>>正文


Java Toolbar.setOnClickListener方法代码示例

本文整理汇总了Java中android.support.v7.widget.Toolbar.setOnClickListener方法的典型用法代码示例。如果您正苦于以下问题:Java Toolbar.setOnClickListener方法的具体用法?Java Toolbar.setOnClickListener怎么用?Java Toolbar.setOnClickListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.support.v7.widget.Toolbar的用法示例。


在下文中一共展示了Toolbar.setOnClickListener方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCreate

import android.support.v7.widget.Toolbar; //导入方法依赖的package包/类
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_event_content);
    recyclerView= (RecyclerView) findViewById(R.id.recycler_view);
    list=new ArrayList<>();
    adapter=new EventAdapter(this,list);
    toolbar= (Toolbar) findViewById(R.id.Event_toolbar);
    toolbar.setNavigationIcon(R.drawable.backbutton);
    toolbar.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            finish();
        }
    });
    RecyclerView.LayoutManager layoutManager=new GridLayoutManager(this,2);  // 2 is the number of columns in grid view
    recyclerView.setLayoutManager(new GridLayoutManager(this,2));
    recyclerView.addItemDecoration(new GridSpacingItemDecoration(2,dpToPx(10),true));
    recyclerView.setItemAnimator(new DefaultItemAnimator());
    recyclerView.setAdapter(adapter);
    initialize();

}
 
开发者ID:rishabh115,项目名称:Odyssey2017,代码行数:24,代码来源:EventActivity.java

示例2: onCreate

import android.support.v7.widget.Toolbar; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_ithome);

  toolbar = (Toolbar) findViewById(R.id.toolbar);
  toolbar.setTitle(R.string.ithome);
  toolbar.setNavigationOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
      ITHomeActivity.this.finish();
    }
  });
  toolbar.setOnClickListener(new DoubleClickBackToContentTopListener(this));

  refreshLayout = (SwipeRefreshLayout) findViewById(R.id.refresh_layout);
  listView = (ListView) findViewById(R.id.list_view);
  adapter = new SimpleAdapter(this, data, R.layout.list_view_item_ithome, new String[]{"title", "href"}, new int[]{R.id.title, R.id.href});
  listView.setAdapter(adapter);
  loadMoreFooter = new LoadMoreFooter(this, listView, this);

  refreshLayout.setOnRefreshListener(this);
  listView.setOnItemClickListener(this);

  refreshLayout.setRefreshing(true);
  initData();

}
 
开发者ID:tomoya92,项目名称:android-apps,代码行数:29,代码来源:ITHomeActivity.java

示例3: onCreate

import android.support.v7.widget.Toolbar; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main_activity);

    errorContainer = (LinearLayout) findViewById(R.id.error_container);
    ImageButton errorIcon = (ImageButton) findViewById(R.id.error_icon);
    errorIcon.setOnClickListener(this);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    applyFontsToTitle(toolbar);

    list = (RecyclerView) findViewById(R.id.list);
    refresh = (SwipeRefreshLayout) findViewById(R.id.refreshLayout);

    toolbar.setOnClickListener(v -> list.scrollToPosition(0));

    url = getString(R.string.pic_category_url, 21, page);
    setupRecyclerView();

    toolbar.setOnClickListener(v -> list.scrollToPosition(0));

    loadData(true);
}
 
开发者ID:Assassinss,项目名称:Moment,代码行数:26,代码来源:MainActivity.java

示例4: setUpUI

import android.support.v7.widget.Toolbar; //导入方法依赖的package包/类
private void setUpUI() {

        //Default colors
        defaultPrimaryColor = ContextCompat.getColor(this, R.color.md_blue_grey_800);
        defaultSecondaryColor = ContextCompat.getColor(this, R.color.md_teal_a400);
        defaultTextColor = ContextCompat.getColor(this, R.color.md_white);

        // Toolbar
        mToolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(mToolbar);
        mToolbar.setOnClickListener(this);

        // Wire the floating button
        mFab = (FloatingActionButton) findViewById(R.id.fab);
        mFab.setOnClickListener(this);
        mFab.setOnLongClickListener(this);
    }
 
开发者ID:IdeaTrackerPlus,项目名称:IdeaTrackerPlus,代码行数:18,代码来源:MainActivity.java

示例5: startDebugActivity

import android.support.v7.widget.Toolbar; //导入方法依赖的package包/类
public static void startDebugActivity(Toolbar toolbar, final Activity activity) {
    toolbar.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            if (System.currentTimeMillis() - BlackTech.sCurrentTime < 500) {
                BlackTech.sTimes++;
            } else {
                BlackTech.sTimes = 1;
            }
            BlackTech.sCurrentTime = System.currentTimeMillis();
            if (BlackTech.sTimes == 5) {
                BlackTech.sTimes = 0;
                ChangeEnvironmentActivity.comeOnBaby(activity);
            }
        }
    });
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:17,代码来源:BlackTech.java

示例6: initToolbar

import android.support.v7.widget.Toolbar; //导入方法依赖的package包/类
private void initToolbar() {
    Toolbar toolbar = findViewById(R.id.actionBarChat);
    toolbar.setTitleTextColor(ContextCompat.getColor(getApplicationContext(), android.R.color.white));
    toolbar.setTitle(cname);
    setSupportActionBar(toolbar);
    getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_arrow_left);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeButtonEnabled(true);
    if (ctype != Chat.ChatType.PRIVATE && Utils.getController().getMessengerDatabase().userInChat(Utils.getUserID(), cid)) {
        toolbar.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivityForResult(new Intent(getApplicationContext(), ChatEditActivity.class)
                        .putExtra("cid", cid)
                        .putExtra("cname", cname), 1);
            }
        });
    }
}
 
开发者ID:LCA311,项目名称:leoapp-sources,代码行数:20,代码来源:ChatActivity.java

示例7: setToolbar

import android.support.v7.widget.Toolbar; //导入方法依赖的package包/类
/**
 * 如果存在Toolbar在子类中调用setToolbar方法
 *
 * @param isBack
 */
protected void setToolbar(boolean isBack) {
    mAppBar = (AppBarLayout) findViewById(R.id.appbar);
    mToolbar = (Toolbar) findViewById(R.id.toolbar);
    if (mAppBar == null || mToolbar == null) {
        throw new IllegalStateException("The subClass must contain a AppBarLayout and Toolbar");
    }
    mToolbar.setOnClickListener(view -> onToolbarClick());
    setSupportActionBar(mToolbar);
    if (isBack) {
        ActionBar actionBar = getSupportActionBar();
        if (actionBar != null) actionBar.setDisplayHomeAsUpEnabled(true);
    }
}
 
开发者ID:weixianshishen,项目名称:BeautifulGirls,代码行数:19,代码来源:BaseActivity.java

示例8: initToolbar

import android.support.v7.widget.Toolbar; //导入方法依赖的package包/类
/**
 * 初始化Toolbar
 */
protected void initToolbar() {
    Toolbar toolbar = mToolbar;
    toolbar.setNavigationIcon(R.drawable.ic_back);
    toolbar.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            getActivity().finish();
        }
    });
}
 
开发者ID:FZZFVII,项目名称:pipe,代码行数:14,代码来源:ChatFragment.java

示例9: onCreate

import android.support.v7.widget.Toolbar; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_w3cplus);

  toolbar = (Toolbar) findViewById(R.id.toolbar);
  toolbar.setTitle(R.string.w3cplus);
  toolbar.setNavigationOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
      W3cplusActivity.this.finish();
    }
  });
  toolbar.setOnClickListener(new DoubleClickBackToContentTopListener(this));

  refreshLayout = (SwipeRefreshLayout) findViewById(R.id.refresh_layout);
  listView = (ListView) findViewById(R.id.list_view);
  adapter = new MyBaseAdapter<Map<String, Object>>(this, data) {
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
      ViewHolder holder = ViewHolder.get(context, convertView, parent, R.layout.list_view_item_w3cplus, position);
      Map<String, Object> map = _data.get(position);
      holder.setText(R.id.title, map.get("title").toString())
          .setText(R.id.time, map.get("time").toString())
          .setText(R.id.desc, map.get("desc").toString())
          .setText(R.id.author, map.get("author").toString());
      return holder.getConvertView();
    }
  };
  listView.setAdapter(adapter);
  loadMoreFooter = new LoadMoreFooter(this, listView, this);

  refreshLayout.setOnRefreshListener(this);
  listView.setOnItemClickListener(this);

  refreshLayout.setRefreshing(true);
  initData();
}
 
开发者ID:tomoya92,项目名称:android-apps,代码行数:39,代码来源:W3cplusActivity.java

示例10: onCreate

import android.support.v7.widget.Toolbar; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_toutiaocom);

  toolbar = (Toolbar) findViewById(R.id.toolbar);
  toolbar.setTitle(R.string.toutiaocom);
  toolbar.setNavigationOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
      TouTiaoComActivity.this.finish();
    }
  });
  toolbar.setOnClickListener(new DoubleClickBackToContentTopListener(this));

  refreshLayout = (SwipeRefreshLayout) findViewById(R.id.refresh_layout);
  listView = (ListView) findViewById(R.id.list_view);
  adapter = new MyBaseAdapter<Map<String, Object>>(this, data) {
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
      ViewHolder holder = ViewHolder.get(TouTiaoComActivity.this, convertView, parent, R.layout.list_view_item_toutiaocom, position);
      Map map = _data.get(position);
      holder.setText(R.id.title, "[" + map.get("article_genre").toString() + "] " + map.get("title").toString())
          .setText(R.id.href, "http://www.toutiao.com/a" + map.get("group_id").toString());
      return holder.getConvertView();
    }
  };
  listView.setAdapter(adapter);
  loadMoreFooter = new LoadMoreFooter(this, listView, this);

  refreshLayout.setOnRefreshListener(this);
  listView.setOnItemClickListener(this);

  refreshLayout.setRefreshing(true);
  initData();

}
 
开发者ID:tomoya92,项目名称:android-apps,代码行数:38,代码来源:TouTiaoComActivity.java

示例11: onCreate

import android.support.v7.widget.Toolbar; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_tuicool);

  toolbar = (Toolbar) findViewById(R.id.toolbar);
  toolbar.setTitle(R.string.tuicool);
  toolbar.setNavigationOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
      TuiCoolActivity.this.finish();
    }
  });
  toolbar.setOnClickListener(new DoubleClickBackToContentTopListener(this));

  refreshLayout = (SwipeRefreshLayout) findViewById(R.id.refresh_layout);
  listView = (ListView) findViewById(R.id.list_view);
  adapter = new MyBaseAdapter<Map<String, Object>>(this, data) {
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
      ViewHolder holder = ViewHolder.get(context, convertView, parent, R.layout.list_view_item_tuicool, position);
      Map<String, Object> map = _data.get(position);
      holder.setText(R.id.title, map.get("title").toString())
          .setText(R.id.time, map.get("time").toString())
          .setText(R.id.source, map.get("source").toString());
      holder.setNetImage(R.id.img, map.get("img").toString());
      return holder.getConvertView();
    }
  };
  listView.setAdapter(adapter);
  loadMoreFooter = new LoadMoreFooter(this, listView, this);

  refreshLayout.setOnRefreshListener(this);
  listView.setOnItemClickListener(this);

  refreshLayout.setRefreshing(true);
  initData();
}
 
开发者ID:tomoya92,项目名称:android-apps,代码行数:39,代码来源:TuiCoolActivity.java

示例12: onCreate

import android.support.v7.widget.Toolbar; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_toutiaoio);

  toolbar = (Toolbar) findViewById(R.id.toolbar);
  toolbar.setTitle(R.string.toutiaoio);
  toolbar.setNavigationOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
      TouTiaoIOActivity.this.finish();
    }
  });
  toolbar.setOnClickListener(new DoubleClickBackToContentTopListener(this));

  refreshLayout = (SwipeRefreshLayout) findViewById(R.id.refresh_layout);
  listView = (ListView) findViewById(R.id.list_view);
  adapter = new MyBaseAdapter<Map<String, Object>>(this, data) {
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
      ViewHolder holder = ViewHolder.get(context, convertView, parent, R.layout.list_view_item_toutiaoio, position);
      Map<String, Object> map = _data.get(position);
      holder.setText(R.id.title, map.get("title").toString())
          .setText(R.id.replyCount, map.get("replyCount").toString())
          .setText(R.id.source, map.get("source").toString());
      holder.setNetImage(R.id.avatar, map.get("avatar").toString());
      return holder.getConvertView();
    }
  };
  listView.setAdapter(adapter);
  loadMoreFooter = new LoadMoreFooter(this, listView, this);

  refreshLayout.setOnRefreshListener(this);
  listView.setOnItemClickListener(this);

  refreshLayout.setRefreshing(true);
  initData();
}
 
开发者ID:tomoya92,项目名称:android-apps,代码行数:39,代码来源:TouTiaoIOActivity.java

示例13: onCreate

import android.support.v7.widget.Toolbar; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_newsbrother);

  toolbar = (Toolbar) findViewById(R.id.toolbar);
  toolbar.setTitle(R.string.newsbrother);
  toolbar.setNavigationOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
      NewsBrotherActivity.this.finish();
    }
  });
  toolbar.setOnClickListener(new DoubleClickBackToContentTopListener(this));

  refreshLayout = (SwipeRefreshLayout) findViewById(R.id.refresh_layout);
  listView = (ListView) findViewById(R.id.list_view);
  adapter = new MyBaseAdapter<Map<String, Object>>(this, data) {
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
      ViewHolder holder = ViewHolder.get(NewsBrotherActivity.this, convertView, parent, R.layout.list_view_item_newsbrother, position);
      Map map = _data.get(position);
      holder.setText(R.id.title, map.get("title").toString())
          .setText(R.id.author, map.get("author").toString())
          .setText(R.id.time, map.get("time").toString());
      return holder.getConvertView();
    }
  };
  listView.setAdapter(adapter);
  loadMoreFooter = new LoadMoreFooter(this, listView, this);

  refreshLayout.setOnRefreshListener(this);
  listView.setOnItemClickListener(this);

  refreshLayout.setRefreshing(true);
  initData();

}
 
开发者ID:tomoya92,项目名称:android-apps,代码行数:39,代码来源:NewsBrotherActivity.java

示例14: initMenu

import android.support.v7.widget.Toolbar; //导入方法依赖的package包/类
private void initMenu(ViewHolder holder) {
    Toolbar toolbar = holder.get(R.id.toolbar);
    toolbar.setLogo(R.mipmap.logo_actionbar);
    toolbar.setTitle("");
    DrawerLayout drawer = holder.get(R.id.drawer_layout);
    setSupportActionBar(toolbar);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
            this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.setDrawerListener(toggle);
    toggle.syncState();
    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);

    // 双击 666
    final GestureDetector detector = new GestureDetector(this, new GestureDetector.SimpleOnGestureListener() {
        @Override
        public boolean onDoubleTap(MotionEvent e) {
            quickToTop();   // 快速返回头部
            return super.onDoubleTap(e);
        }
    });

    toolbar.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            detector.onTouchEvent(event);
            return false;
        }
    });

    toolbar.setOnClickListener(this);

    holder.setOnClickListener(this, R.id.fab);

    loadMenuData();
}
 
开发者ID:GcsSloop,项目名称:diycode,代码行数:37,代码来源:MainActivity.java

示例15: onCreate

import android.support.v7.widget.Toolbar; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_importnew);

  toolbar = (Toolbar) findViewById(R.id.toolbar);
  toolbar.setTitle(R.string.importnew);
  toolbar.setNavigationOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
      ImportNewActivity.this.finish();
    }
  });
  toolbar.setOnClickListener(new DoubleClickBackToContentTopListener(this));

  refreshLayout = (SwipeRefreshLayout) findViewById(R.id.refresh_layout);
  refreshLayout.setOnRefreshListener(this);
  recylerView = (RecyclerView) findViewById(R.id.recylerView);
  recylerView.setLayoutManager(new LinearLayoutManager(this));
  recylerView.addItemDecoration(new MyRecylerViewAdapter.DividerItemDecoration(this, MyRecylerViewAdapter.DividerItemDecoration.VERTICAL_LIST));
  adapter = new MyRecylerViewAdapter<Map<String, Object>>(this, data) {
    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
      switch (viewType) {
        case -1:
          return new TypeViewHolder(inflater.inflate(R.layout.recylerview_footer_load_more, parent, false)) {
            @Override
            public void bindHolder(Map<String, Object> model) {

            }
          };
        case 0:
          return new TypeViewHolder(inflater.inflate(R.layout.list_view_item_importnew, parent, false)) {
            @Override
            public void bindHolder(Map<String, Object> model) {
              this.setText(R.id.title, model.get("title").toString())
                  .setText(R.id.desc, model.get("desc").toString())
                  .setText(R.id.time, model.get("time").toString())
                  .setText(R.id.catagray, model.get("catagray").toString())
                  .setText(R.id.replyCount, model.get("replyCount").toString());
              this.setNetImage(R.id.img, model.get("img").toString());
            }
          };
        default:
          return null;
      }
    }

    @Override
    public int getItemViewType(int position) {
      if (super.list.get(position) == null) return -1;
      return 0;
    }
  };

  recylerView.setAdapter(adapter);
  adapter.setOnItemClickListener(this);
  recylerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
    @Override
    public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
      super.onScrolled(recyclerView, dx, dy);
      LinearLayoutManager layoutManager = (LinearLayoutManager) recyclerView.getLayoutManager();
      int totalItemCount = layoutManager.getItemCount();
      int lastVisibleItem = layoutManager.findLastVisibleItemPosition();
      if (!loading && totalItemCount < lastVisibleItem + 3) {
        page++;
        initData();
        loading = true;
      }
    }
  });
  refreshLayout.setRefreshing(true);
  initData();

}
 
开发者ID:tomoya92,项目名称:android-apps,代码行数:76,代码来源:ImportNewActivity.java


注:本文中的android.support.v7.widget.Toolbar.setOnClickListener方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。