对于IonicReact.js我需要传递图像数组,以便可以向模态添加下一个和上一个感兴趣的读者,本文将会是一篇不错的选择,并为您提供关于android–下一个和上一个动画、android–从listv
对于Ionic React.js我需要传递图像数组,以便可以向模态添加下一个和上一个感兴趣的读者,本文将会是一篇不错的选择,并为您提供关于android – 下一个和上一个动画、android – 从listview获取下一个和上一个详细数据、AngularJS – ForEach访问上一个/下一个索引数组,可能吗?、Bootstrap Carousel显示下一个和上一个图像的有用信息。
本文目录一览:- Ionic React.js我需要传递图像数组,以便可以向模态添加下一个和上一个
- android – 下一个和上一个动画
- android – 从listview获取下一个和上一个详细数据
- AngularJS – ForEach访问上一个/下一个索引数组,可能吗?
- Bootstrap Carousel显示下一个和上一个图像
Ionic React.js我需要传递图像数组,以便可以向模态添加下一个和上一个
在我看来,这个组件似乎只处理一个图像,并且您在JSX中有一个较高组件的一行,类似于以下内容,您在其中传递了一个包含要显示的图像数据的prop: / p>
user
在这种情况下,需要上一个/下一个控件是此更高的组件,然后将图像数组中用于“当前”所需图像的另一组数据传递给ProductImagesItem组件。
android – 下一个和上一个动画
当用户选择列表中的项目时,我弹出了PopupWindow.然后当他在弹出窗口中左右滑动时,数据(在弹出窗口中)分别变为列表中的上一个和下一个项目.
我已经做到这一点,当用户向右滑动手指(“下一步”动作)时,当左边的当前窗口从屏幕右侧熄灭时,它看起来像是从左侧滑入的新弹出窗口.反之亦然“上一步”动议.
但问题是,因为我为两个动画制作了两种风格(左到中间,中间到右边,右到中间,中间到左边),而且PopupWindows没有更新显示,当用户向右滑动(“下一步”)然后向左滑动(“上一步”)时,动画看起来不稳定,因为2个动画重叠.当滑动再次反转时也会发生同样的情况.
现在,如果我在更改动画后调用update(),它会再次滑入中间.那更糟糕的是.那么我能做些什么来实现我想要的行为呢?
谢谢.
编辑:源代码
这是我用来第一次显示弹出窗口的代码:
popup1 = new PopupWindow(popupLayout, popup_width, popup_height, true);
popup1.setAnimationStyle(R.style.AnimationPopup);
popup1.showAtLocation(this.findViewById(R.id.main_container), Gravity.CENTER, 0, 0);
这是next()方法的代码:
if(popup2 != null) popup1 = popup2;
if(popup1 != null) {
popup2 = new PopupWindow(popupLayout, popup_width, popup_height, true);
popup2.setAnimationStyle(R.style.AnimationPopup);
popup1.dismiss();
popup2.showAtLocation(rootLayout, Gravity.CENTER, 0, 0);
}
这是prev()方法的代码:
if(popup2 != null) popup1 = popup2;
if(popup1 != null) {
popup2 = new PopupWindow(popupLayout, popup_width, popup_height, true);
popup2.setAnimationStyle(R.style.AnimationPopupReverse);
popup1.setAnimationStyle(R.style.AnimationPopupReverse);
popup1.dismiss();
popup2.showAtLocation(rootLayout, Gravity.CENTER, 0, 0);
}
这就是Java代码的全部内容. AnimationPopup是一个XML,可以简单地显示从右到中的幻灯片以及从中心到左侧动画的隐藏幻灯片.而AnimationPopupReverse与上述动画相反.
我已经提供了我的第一次尝试代码.此处,更改的动画在显示另一个弹出窗口后生效.
解决方法:
如果在应用程序标记下的清单中使用android:hardwareAccelerated =“true”,则所有动画都会显得更清晰.即使是常规的幻灯片左/右动画也不会出现硬件加速.
android – 从listview获取下一个和上一个详细数据
我不知道如何通过单击基于listview的下一个/上一个按钮来显示下一个/上一个详细数据的功能.
这是我想要做的截图
My listview Activity
My Detail data Activity,显示listview中的下一个/上一个数据
编辑:我有一个listview数据(使用xml解析器),并将数据传递给名为“Detail_toko.class”的新活动:
List<NameValuePair> paramemeter = new ArrayList<NameValuePair>();
paramemeter.add(new BasicNameValuePair("keyword", "a"));
// paramemeter.add(new BasicNameValuePair("kategori",Category.getSelectedItem().toString()));
XMLParser parser = new XMLParser();
String xml = parser.getXmlFromUrl(URL, paramemeter); // getting XML from URL
Document doc = parser.getDomElement(xml); // getting DOM element
NodeList nl = doc.getElementsByTagName(TAG_DETAIL);
// looping through all song nodes <song>
for (int i = 0; i < nl.getLength(); i++) {
// creating new HashMap
HashMap<String, String> map = new HashMap<String, String>();
Element e = (Element) nl.item(i);
// adding each child node to HashMap key => value
map.put(TAG_ID, parser.getValue(e, TAG_ID));
map.put(TAG_NAMATOKO, parser.getValue(e, TAG_NAMATOKO));
map.put(TAG_KATEGORI, parser.getValue(e, TAG_KATEGORI));
map.put(TAG_EMAIL, parser.getValue(e, TAG_EMAIL));
map.put(TAG_ICON, parser.getValue(e, TAG_ICON));
// adding HashList to ArrayList
PremiumList.add(map);
}
return null;
}
/**
* Updating parsed JSON data into ListView
* */
list=(ListView)findViewById(R.id.listview);
if(PremiumList.size() > 0)
{
adapter=new LazyAdapterStore(ListPerusahaan.this, PremiumList);
list.setAdapter(adapter);
}
else
{
Toast toast= Toast.makeText(getApplicationContext(), "No data found, enter another keyword", Toast.LENGTH_SHORT);
toast.setGravity(Gravity.CENTER_VERTICAL|Gravity.CENTER_HORIZONTAL, 0, 0);
toast.show();
}
// Click event for single list row
list.setonItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
// getting values from selected ListItem
String nama_toko = ((TextView) view.findViewById(R.id.nama_toko)).getText().toString();
String kategori = ((TextView) view.findViewById(R.id.kategori)).getText().toString();
String email = ((TextView) view.findViewById(R.id.email)).getText().toString();
PremiumList = new ArrayList<HashMap<String, String>>();
Intent in = new Intent(ListPerusahaan.this, Detail_toko.class);
in.putExtra("PremiumList", PremiumList);
//in.putStringArrayListExtra( "PremiumList", PremiumList );
in.putExtra("position", position);
in.putExtra("TotalData", TotalData);
in.putExtra(TAG_NAMATOKO, nama_toko);
in.putExtra(TAG_KATEGORI, kategori);
in.putExtra(TAG_EMAIL, email);
startActivity(in);
这是我的LazyAdapterStore代码:
public View getView(int position, View convertView, ViewGroup parent) {
View vi=convertView;
if(convertView==null)
vi = inflater.inflate(R.layout.list_data_store, null);
TextView nama_toko = (TextView)vi.findViewById(R.id.nama_toko); // title
TextView kategori = (TextView)vi.findViewById(R.id.kategori); // title
ImageView thumb_image=(ImageView)vi.findViewById(R.id.list_image); // thumb image
TextView email = (TextView)vi.findViewById(R.id.email); // artist name
HashMap<String, String> detail = new HashMap<String, String>();
detail = data.get(position);
// Setting all values in listview
nama_toko.setText(detail.get(ListPerusahaan.TAG_NAMATOKO));
kategori.setText(detail.get(ListPerusahaan.TAG_KATEGORI));
email.setText(detail.get(ListPerusahaan.TAG_EMAIL));
imageLoader.displayImage(detail.get(ListPerusahaan.TAG_ICON), thumb_image);
return vi;
}
编辑:而且,这是我的新活动“Detail_Toko”,用于显示listview项目的详细数据:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//this must be called BEFORE setContentView
requestwindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.detail_toko);
getwindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.window_title);
call_btn=(Button)findViewById(R.id.call);
email_btn=(Button)findViewById(R.id.email);
sms_btn=(Button)findViewById(R.id.sms);
Next_btn=(Button)findViewById(R.id.Next);
Prev_btn=(Button)findViewById(R.id.Prev);
phonenumber=(TextView)findViewById(R.id.telpon);
// getting intent data
Intent in = getIntent();
// @SuppressWarnings("unchecked")
//ArrayList<HashMap<String, String>> PremiumList = (ArrayList<HashMap<String, String>>) getIntent().getSerializableExtra("PremiumList");
// Get String values from prevIoUs intent
final String nama_toko = in.getStringExtra(TAG_NAMATOKO);
final String kategori = in.getStringExtra(TAG_KATEGORI);
final String email = in.getStringExtra(TAG_EMAIL);
// Get Int values from prevIoUs intent
final int posisi = in.getExtras().getInt("position");
final int Total_data = in.getExtras().getInt("TotalData");
/*
Bundle bundle = in.getExtras();
HashMap<String, String> list = (HashMap<String, String>) bundle.getSerializable("PremiumList");
list = data.get(currentposition);
*/
Bundle bundle = in.getExtras();
HashMap<String, String> list = (HashMap<String, String>) bundle.getSerializable("PremiumList");
list = data.get(currentposition);
// displaying all values on the screen
lblPosisi = (TextView) findViewById(R.id.namatoko);
lbltotaldata = (TextView) findViewById(R.id.nama);
lblNamatoko = (TextView) findViewById(R.id.nama_toko);
lblKategori = (TextView) findViewById(R.id.kategori);
lblEmail = (TextView) findViewById(R.id.textemail);
lblPosisi.setText(String.valueOf(posisi));
lbltotaldata.setText(String.valueOf(Total_data));
lblNamatoko.setText(nama_toko);
lblKategori.setText(kategori);
lblEmail.setText(email);
// Set the int value of currentposition from prevIoUs selected listview item
currentposition = posisi;
Next_btn.setonClickListener(new Button.OnClickListener(){
public void onClick(View v){
if(currentposition >= Total_data - 1)
{
Toast toast= Toast.makeText(getApplicationContext(), "Last Record", Toast.LENGTH_SHORT);
toast.setGravity(Gravity.CENTER_VERTICAL|Gravity.CENTER_HORIZONTAL, 0, 0);
toast.show();
}
else
{
currentposition++;
lblPosisi.setText(String.valueOf(currentposition));
lblNamatoko.setText(list.get(nama_toko));
lblKategori.setText(list.get(kategori));
lblEmail.setText(list.get(email));
}
}
});
Prev_btn.setonClickListener(new Button.OnClickListener(){
public void onClick(View v){
if(currentposition <= 0)
{
Toast toast= Toast.makeText(getApplicationContext(), "First Record", Toast.LENGTH_SHORT);
toast.setGravity(Gravity.CENTER_VERTICAL|Gravity.CENTER_HORIZONTAL, 0, 0);
toast.show();
}
else
{
currentposition--;
lblPosisi.setText(String.valueOf(currentposition));
lblNamatoko.setText(list.get(nama_toko));
lblKategori.setText(list.get(kategori));
lblEmail.setText(list.get(email));
}
}
});
问题是,我不知道如何通过单击“Detail_toko”活动中的下一个/上一个按钮来创建一个函数来显示listview中的下一个/上一个详细数据.
请有人帮我…
预先感谢
解决方法:
刚看到你在上一篇文章中的请求.
Parvaz给出的解决方案是完美的,你只需要弄清楚代码.
你有一个arraylist“PremiumList”,它负责你的listview行数据.
您所需要的只是将位置和此列表传递给Detail_toko.class(通过意图使用parceable或声明arraylist作为静态(不推荐)等)并且您的解决方案将是几步之遥.
在Detail_toko.class中创建一个全局变量currentPosition,它将从过去的活动中获取其值,例如来自intent的TAG_NAMATOKO.
然后在NEXT按钮的onClickListener中将1递增到currentPosition,并从刚刚从上一个活动传输的arraylist获取详细信息,就像在getView方法中一样.
HashMap<String, String> detail = new HashMap<String, String>();
detail = data.get(currentPosition);
// Setting all values in listview
nama_toko = detail.get(ListPerusahaan.TAG_NAMATOKO);
kategori = detail.get(ListPerusahaan.TAG_KATEGORI);
email = detail.get(ListPerusahaan.TAG_EMAIL);
设置这些值,您的新视图将相应更新.
在PREVIoUS的onClickListener按钮从currentPosition递减1,后跟相同的代码(这意味着你必须创建一个方法并调用它,不重复代码).
试试吧.这是我们可以解释的详细信息,而不实际做功课!
编辑:
首先从OnItemClick中删除此行
PremiumList = new ArrayList<HashMap<String, String>>();
您正在清除此行中PremiumList的所有数据,这样您将在下一个活动中获得空白列表.所以摆脱这条线.
一旦你在下一个活动中获得PremiumList,你需要的就是位置和totalData以及额外的intent.
您可以从额外的意图中删除TAG_NAMATOKO,TAG_KATEGORI,TAG_EMAIL.
我曾告诉过你不要重复这段代码,因为你是初学者,因为它会让你的生活变得轻松,因此非常重要.
采取这些考虑并使你的习惯.
现在,您在“Detail_Toko”中的代码将变为:
HashMap<String, String> list = null;
int currentposition = 0;
int Total_data =0;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//this must be called BEFORE setContentView
requestwindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.detail_toko);
getwindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.window_title);
call_btn=(Button)findViewById(R.id.call);
email_btn=(Button)findViewById(R.id.email);
sms_btn=(Button)findViewById(R.id.sms);
Next_btn=(Button)findViewById(R.id.Next);
Prev_btn=(Button)findViewById(R.id.Prev);
phonenumber=(TextView)findViewById(R.id.telpon);
// displaying all values on the screen
lblPosisi = (TextView) findViewById(R.id.namatoko);
lbltotaldata = (TextView) findViewById(R.id.nama);
lblNamatoko = (TextView) findViewById(R.id.nama_toko);
lblKategori = (TextView) findViewById(R.id.kategori);
lblEmail = (TextView) findViewById(R.id.textemail);
// getting intent data
Bundle bundle = getIntent().getExtras();
// Get Int values from prevIoUs intent
currentposition = bundle.getInt("position");
Total_data = bundle.getInt("TotalData");
list = (HashMap<String, String>) bundle.get("PremiumList");
setView();
Next_btn.setonClickListener(new Button.OnClickListener(){
public void onClick(View v){
if(currentposition >= Total_data - 1)
{
Toast toast= Toast.makeText(getApplicationContext(), "Last Record", Toast.LENGTH_SHORT);
toast.setGravity(Gravity.CENTER_VERTICAL|Gravity.CENTER_HORIZONTAL, 0, 0);
toast.show();
}
else
{
currentposition++;
setView();
}
}
});
Prev_btn.setonClickListener(new Button.OnClickListener(){
public void onClick(View v){
if(currentposition <= 0)
{
Toast toast= Toast.makeText(getApplicationContext(), "First Record", Toast.LENGTH_SHORT);
toast.setGravity(Gravity.CENTER_VERTICAL|Gravity.CENTER_HORIZONTAL, 0, 0);
toast.show();
}
else
{
currentposition--;
setView();
}
}
});
private void setView()
{
if(list != null && list.size() > currentposition)
{
HashMap<String, String> detail = new HashMap<String, String>();
detail = list.get(currentposition);
lblPosisi.setText(String.valueOf(currentposition));
lbltotaldata.setText(String.valueOf(Total_data));
lblNamatoko.setText(detail.get(ListPerusahaan.TAG_NAMATOKO));
lblKategori.setText(detail.get(ListPerusahaan.TAG_KATEGORI));
lblEmail.setText(detail.get(ListPerusahaan.TAG_EMAIL));
}
}
建议:使用ViewHolder在getView方法中填充视图,它将使您的适配器“一个高效的适配器”. (搜索示例)
遵循命名约定和所有.
在使用它们之前检查anyObject!= null,它们的大小或长度以及bundle.containKey等东西,以避免像nullPointerException这样的致命异常.
AngularJS – ForEach访问上一个/下一个索引数组,可能吗?
$scope.todos = [ {text:'learn',done:true},{text:'build',done:false},{text:'watch',{text:'destroy',{text:'rebuild',done:false}]; $scope.remaining = function() { var count = 0; angular.forEach($scope.todos,function(todo,i) { todo.text = 'want2learn'; todo.text[i+1] = todo.text; });
是否有可能ForEach函数访问/设置对象的上一个/下一个索引数组值,可能吗?
解决方法
$scope.todos[i+1].text = todo.text;
你想要防止索引超过数组的末尾:
if(i < $scope.todos.length - 1) { $scope.todos[i+1].text = todo.text; }
Bootstrap Carousel显示下一个和上一个图像
引导轮播是否可扩展以在滑块中显示下一个和上一个图像?
<div id="carousel-example-generic"data-ride="carousel" data-interval="false">
<!-- Indicators -->
<ol>
<li data-target="#carousel-example-generic" data-slide-to="0"></li>
<li data-target="#carousel-example-generic" data-slide-to="1"></li>
</ol>
<!-- Wrapper for slides -->
<div>
<div>
<img src="img/bike.png" alt="...">
<div>
...
</div>
</div>
<div>
<img src="img/bike2.png" alt="...">
<div>
...
</div>
</div>
</div>
<!-- Controls -->
<ahref="#carousel-example-generic" data-slide="prev">
<span></span>
</a>
<ahref="#carousel-example-generic" data-slide="next">
<span></span>
</a>
</div>
目前,我的轮播看起来像这样,如何将上一张和下一张图像添加到当前活动的幻灯片中?
今天关于Ionic React.js我需要传递图像数组,以便可以向模态添加下一个和上一个的介绍到此结束,谢谢您的阅读,有关android – 下一个和上一个动画、android – 从listview获取下一个和上一个详细数据、AngularJS – ForEach访问上一个/下一个索引数组,可能吗?、Bootstrap Carousel显示下一个和上一个图像等更多相关知识的信息可以在本站进行查询。
本文标签: