- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 viewPager,我希望在操作栏上有一个按案例打开新 Activity 的项目,我的意思是,如果当前图像为 1,则打开 Activity1,如果它是第二个,则它应该打开 Activity2。到现在为止,我已经创建了包含项目的菜单,并打开了新的 Activity ,但我希望通过上面描述的案例打开更多 Activity 。非常感谢!!!
MainActivity.java:
package com.descoper.rom;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Parcelable;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.PagerTitleStrip;
import android.support.v4.view.ViewPager;
import android.view.Gravity;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.Toast;
import android.view.View.OnClickListener;
public class MainActivity extends Activity {
private static int NUM_VIEWS = 46;
private MyPagerAdapter adapter;
private ViewPager pager;
private int[] pics = { R.drawable.casapoporului, R.drawable.transfagarasan,
R.drawable.transalpina, R.drawable.balealac,
R.drawable.barajulsiriu, R.drawable.bisericadesublac,
R.drawable.canionulscari, R.drawable.cascadacailor,
R.drawable.cascadaciucas, R.drawable.castelulbran,
R.drawable.castelulcorvinilor, R.drawable.castelulkaroly,
R.drawable.castelulpeles, R.drawable.castelulsturdza,
R.drawable.castrulroman, R.drawable.cazaneledunarii,
R.drawable.cazinoulconstanta, R.drawable.cetateabastionara,
R.drawable.cetateafagaras, R.drawable.cetateaprejmer,
R.drawable.cheilebicazului, R.drawable.cimitirulsapanta,
R.drawable.colibita, R.drawable.deltadunarii,
R.drawable.epavacostinesti, R.drawable.focurilevii,
R.drawable.hanulancutei, R.drawable.insulaovidiu,
R.drawable.laculalbastru, R.drawable.laculana,
R.drawable.laculbeului, R.drawable.laculbucura,
R.drawable.laculcapra, R.drawable.laculrosu, R.drawable.laculvidra,
R.drawable.laculvulturilor, R.drawable.mocanita,
R.drawable.parculcraiova, R.drawable.parcultimisoara,
R.drawable.pesteraghetarul, R.drawable.pesteraursilor,
R.drawable.piatabrasov, R.drawable.poduldumnezeu,
R.drawable.salinapraid, R.drawable.salinaturda,
R.drawable.sarmisegetuzaregia, R.drawable.sfinxulbucegi,
R.drawable.sibiu, R.drawable.vulcaniinoroiosi };
@Ghi đè
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
adapter = new MyPagerAdapter();
pager = (ViewPager) findViewById(R.id.myviewpager);
pager.setAdapter(adapter);
PagerTitleStrip pagerTitleStrip = (PagerTitleStrip) findViewById(R.id.titlestrip);
}
@Ghi đè
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.main, menu);
return super.onCreateOptionsMenu(menu);
}
private class MyPagerAdapter extends PagerAdapter {
String[] title = { "Casa poporului", "Transfagarasan", "Transalpina",
"Balea Lac", "Barajul Siriu", "Biserica de sub lac",
"Canionul Sapte scari", "Cascada Cailor", "Cascada Ciucas",
"Castelul Bran", "Castelul Corvinilor", "Castelul Karoly",
"Castelul Peles", "Castelul Sturdza", "Castelul Roman",
"Cazanele Dunarii", "Cazinoul din Constanta",
"Cetatea Bastioara", "Cetatea Fagaras",
"Biserica fortificata de la Prejmer", "Cheile Bicazului",
"Cimitirul vesel din Sapanta", "Lacul Colibita",
"Delta Dunarii", "Epava din Costinesti",
"Focurile Vii de la Luger", "Hanul Ancutei", "Insula Ovidiu",
"Lacul Albastru", "Lacul Sfanta Ana", "Lacul ochiul Beiului",
"Lacul Bucura", "Lacul Capra", "Lacul Rosu", "Lacul Vidra",
"Lacul Vulturilor", "Mocanita din Maramures",
"Parcul Nicolae Romanov din Craiove",
"Piata Operei din Timisoara", "Pestera Scarisoara",
"Pestera Ursilor", "Piata Sfatului din Brasov",
"Podul lui Dumnezeu", "Salina Praid", "Salina Turda",
"Cetatea Sarmizegetusa", "Sfinxul din Bucegi",
"Piata mare din Sibiu", "Vulcanii Noroiosi" };
@Ghi đè
public CharSequence getPageTitle(int position) {
return title[position];
}
@Ghi đè
công khai int getCount() {
return NUM_VIEWS;
}
/**
* Create the page for the given position. The adapter is responsible
* for adding the view to the container given here, although it only
* must ensure this is done by the time it returns from
* {@link #finishUpdate()}.
*
* @param container
* The containing View in which the page will be shown.
* @param position
* The page position to be instantiated.
* @return Returns an Object representing the new page. This does not
* need to be a View, but can be some other container of the
* page.
*/
@Ghi đè
public Object instantiateItem(View bộ sưu tập, int vị trí) {
ImageView view = new ImageView(MainActivity.this);
view.setImageResource(pics[position]);
view.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Toast.makeText(MainActivity.this, "Page" + pics,
Toast.LENGTH_LONG).show();
}
});
((ViewPager) bộ sưu tập).addView(view, 0);
quay lại xem;
}
/**
* Remove a page for the given position. The adapter is responsible for
* removing the view from its container, although it only must ensure
* this is done by the time it returns from {@link #finishUpdate()}.
*
* @param container
* The containing View from which the page will be removed.
* @param position
* The page position to be removed.
* @param object
* The same object that was returned by
* {@link #instantiateItem(View, int)}.
*/
@Ghi đè
public void destroyItem(View collection, int position, Object view) {
((ViewPager) collection).removeView((ImageView) view);
}
@Ghi đè
public boolean isViewFromObject(View view, Object object) {
return view == ((ImageView) object);
}
/**
* Called when the a change in the shown pages has been completed. At
* this point you must ensure that all of the pages have actually been
* added or removed from the container as appropriate.
*
* @param container
* The containing View which is displaying this adapter's
* page views.
*/
@Ghi đè
public void finishUpdate(View arg0) {
}
@Ghi đè
public void restoreState(Parcelable arg0, ClassLoader arg1) {
}
@Ghi đè
public Parcelable saveState() {
trả về giá trị null;
}
@Ghi đè
public void startUpdate(View arg0) {
}
}
@Ghi đè
public boolean onOptionsItemSelected(MenuItem item) {
// Take appropriate action for each action item click
switch (item.getItemId()) {
case R.id.gallery:
startActivity(new Intent(MainActivity.this, Galerie.class));
phá vỡ;
case R.id.ro:
startActivity(new Intent(MainActivity.this, Romania.class));
phá vỡ;
}
trả về false;
}
}
1 Câu trả lời
第 1 步:声明一个变量“frgmnt_Indicator”,用于指示同一 Activity 中的当前页面第 2 步:每次 viewPager 加载新 fragment 时,将相应的值分配给“frgmnt_Indicator”
第 3 步:onOptionItemSelected 方法,检查“frgmnt_Indicator”中的值并相应地在 viewPager 中加载 fragment
在 onOptionItemSelected 方法中
pager.getCurrentItem() 会给你位置,通过位置你知道加载了哪个图像,通过应用开关盒你可以做你想做的事
关于android - 如何在 Android actionbar 中使用 switch-case?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23516403/
Tôi đã tìm kiếm trực tuyến nhưng không tìm thấy bài viết phù hợp nào giải thích cách sử dụng dịch vụ WCF bằng javascript, đặc biệt là WebScriptEndpoint. Có ai có thể hướng dẫn về vấn đề này không? Cảm ơn câu trả lời hay nhất. Đây là bài viết về
Tôi đang viết một chương trình C sẽ chạy các lệnh Linux, ví dụ: cat /etc/passwd | grep list | cut -c 1-5 Tôi không nhận được kết quả nào *ở đây cha đợi con đầu tiên (chi
Vì vậy, tôi đang cố gắng xử lý việc tải tệp lên và sau đó lưu trữ tệp đó vào cơ sở dữ liệu dưới dạng tệp nhị phân. Sau khi lưu trữ, tôi cố gắng phục vụ tệp theo URL đã cho. Có vẻ như tôi không thể tìm ra phương pháp nào hiệu quả ở đây. Tôi cần sử dụng cơ sở dữ liệu vì tôi sử dụng Google Apps
Tôi đang cố gắng tạo một macro thêm công thức bên dưới vào một ô rồi kéo công thức đó xuống toàn bộ cột và sao chép công thức đó vào cột H. Tôi muốn nhập dữ liệu vào cột F và H cho công thức: Range("F1").formula = "=IF(ISE
Vấn đề này tương tự như vấn đề này, nhưng tôi muốn sử dụng OperatorPrecedenceParser để phân tích cú pháp một biểu thức với ứng dụng hàm trong FParsec. Đây là AST của tôi: type Expression =
Tôi muốn thay đổi truy vấn này thành mã bằng cách sử dụng sequelize và node.js tùy thuộc vào nơi select COUNT(gender) as genderCount from customers where
Tôi đang sử dụng GNU bash, phiên bản 5.0.3(1)-release (x86_64-pc-linux-gnu), và tôi tự hỏi tại sao tôi lại gặp lỗi cú pháp cho một câu lệnh gán đơn giản: #/bin/bash var1=/tmp
Sau đây là lý do tại sao mã của tôi không hoạt động trong IE. Mã của tôi hoạt động tốt trên mọi trình duyệt. Không có gì. Nhưng khi tôi chạy dự án của mình trên IE, nó lại phát hiện lỗi. Và lớp jquery và insertadjacentHTMl của tôi không hoạt động
Tôi đang cố gắng thay đổi innerHTML của một thẻ. Tôi không có quyền truy cập vào biểu mẫu nên không thể chỉnh sửa HTML. Mã định danh duy nhất của thẻ là thuộc tính "for". Sau đây là cấu trúc của đầu vào và nhãn:
Tôi có một trang nơi tôi trả về bài đăng của người dùng, có thể bình luận tức thời vào các bài đăng đó bằng một số mã jquery và sau khi có bình luận mới, tôi chèn bình luận mới vào bên dưới bài đăng cùng với nút xóa. Vấn đề là nút Xóa không hoạt động trên phần tử mới được chèn vào,
Tôi có một tệp "phân cách bằng dấu gạch ngang" với khoảng 20 cột. Tôi chỉ muốn băm cột đầu tiên là một số như số tài khoản bằng cách sử dụng sha1sum và trả về phần còn lại của các cột theo nguyên trạng. Cách tốt nhất để thực hiện việc này bằng awk hoặc sed là gì? Tài khoản
Tôi cần chèn nội dung sau vào bảng của mình... Bảng người dùng của tôi có năm cột id, tên người dùng, mật khẩu, tên, mục nhập. (Tôi chưa gửi bất cứ thứ gì vào mục nhập, tôi sẽ làm sau bằng php) nhưng vì lý do nào đó tôi cứ nhận được lỗi này: #1054 - U
Vì vậy, tôi đang cố gắng tạo một trường nhập liệu mà tôi có thể nhập bất kỳ ký tự nào vào đó, sau đó viết thường giá trị đã nhập, xóa mọi ký tự không phải chữ và số, chỉ để lại dấu "." thay cho dấu cách. Ví dụ, nếu tôi nhập: 70% Trái Đất là nước, -!*#$^^ & 30% đất
Tôi đang cố gắng làm một điều mà tôi nghĩ là khá đơn giản nhưng vì lý do nào đó tôi lại không nhận được kết quả như mong muốn? Tôi mới làm quen với javascript nhưng đã có kinh nghiệm với java nên chắc chắn là tôi không sử dụng quy tắc chính xác nào cả. Đây là phương pháp để lấy giá trị đầu vào, kiểm tra lựa chọn
Tôi đang cố gắng tải dữ liệu từ cơ sở dữ liệu mysql bằng angularjs. Ứng dụng hoạt động theo cách này: người dùng đăng nhập và tên người dùng của họ được lưu trữ trong cookie. Tên người dùng này được hiển thị trên trang chủ Tôi muốn lấy giá trị này và truyền nó qua angularjs
Tôi đang sử dụng autoLayout và muốn đặt UIlabel vào UITableViewCell và nó phải luôn nằm ở bên phải và ở giữa ô. Đây là những gì tôi muốn đạt được vì vậy ở đây bạn có thể thấy những gì tôi đang nói đến
Tôi cần truy vấn elasticsearch tương đương với MySql. Truy vấn sql của tôi: SELECT DISTINCT t.product_id AS id FROM tbl_sup_price t
Tôi đang triển khai mã để làm việc với JSON. func setup() { nếu let flickrURL = NSURL(string: "https://api.flickr.com/
Tôi đã thử sử dụng vòng lặp for để khai báo các biến và sau đó kiểm tra xem cols và rols có giống nhau không. Nếu đúng như vậy, nó sẽ chạy hàm đệ quy. Tuy nhiên, tôi đang gặp sự cố khi thực hiện lệnh do trong javascript. Có ai có thể giúp được không? Bây giờ, khi so sánh cột 1 và
Tôi đã đưa ra một ví dụ ngắn về một vấn đề mà tôi đang giải quyết. Mã HTML: 1 2 3 Mã CSS: .BB a:hover{ color: #000; } .BB > li:after {
Tôi là một lập trình viên xuất sắc, rất giỏi!